[GRASS-dev] patch for v.nn.py

Michael,

I've attached a patch to your very useful v.nn.py addon script. The patch provides the following:

- a change of option names from input1,2 to 'from' and 'to'
- the possibility to provide a vector map with polygons giving the contours of the study area for which to calculate the nearest neighbor coefficient - the script just gets the total of all areas and all perimeters in the given map
- the possibility to provide numerical values for area and perimeter

Even though some people argue that the absolute value of the coefficient does not mean much and that the exact size of the study area does not have an influence on the relative values of the coefficient, I think it is a plus to have the possibility to circumscribe the area. Especially since in its current state the module gets the area and perimenter from the current region and as this is a vector module most people won't even think about region settings. (Running the module in the default n=1 s=0 w=0 e=1 region gives very weird coefficient values.

Up to you to decide whether you want to add this into your script.

BTW: the script works perfectly in grass7 as well.

Moritz

(attachments)

v.nn.py.diff (3.98 KB)

On 14/09/13 21:01, Michael Barton wrote:

Moritz,

This is a nice addition.

Actually, not that nice. I just reread one of the papers you give as reference [1] and it clearly states that the equation that you use for estimating the expected mean nearest neighbor distance "cannot be used for irregularly shaped study areas"...

Thanks, I'm really swamped right now. Do you want to add it to the script and add your name to the authors?

I'll see what else I can find in the literature about how to calculate the expected mean distance to see if having the actual study area measures is really useful. If yes, I'll add the patch myself.

BTW, shouldn't the scripts v.nn.py and v.lda.py go into the addons svn ? If you agree then I can add them there, with or without my patch. I've also locally modified v.lda.py a bit to allow easier (to me at least) use of the results.

Moritz

[1] http://www.geog.ucsb.edu/~dongmei/ppa/ppa.html

Michael Barton
School of Human Evolution&Social Change
Center for Social Dynamics& Complexity
Arizona State University

...Sent from my iPad

On Sep 14, 2013, at 9:11 AM, "Moritz Lennert"<mlennert@club.worldonline.be> wrote:

Michael,

I've attached a patch to your very useful v.nn.py addon script. The patch provides the following:

- a change of option names from input1,2 to 'from' and 'to'
- the possibility to provide a vector map with polygons giving the contours of the study area for which to calculate the nearest neighbor coefficient - the script just gets the total of all areas and all perimeters in the given map
- the possibility to provide numerical values for area and perimeter

Even though some people argue that the absolute value of the coefficient does not mean much and that the exact size of the study area does not have an influence on the relative values of the coefficient, I think it is a plus to have the possibility to circumscribe the area. Especially since in its current state the module gets the area and perimenter from the current region and as this is a vector module most people won't even think about region settings. (Running the module in the default n=1 s=0 w=0 e=1 region gives very weird coefficient values.

Up to you to decide whether you want to add this into your script.

BTW: the script works perfectly in grass7 as well.

Moritz
<v.nn.py.diff>

I thought they are in the addons. If not, please feel free to move them there. And thanks again for looking at these. I'm glad they're useful.

Michael
____________________
C. Michael Barton
Director, Center for Social Dynamics & Complexity
Professor of Anthropology, School of Human Evolution & Social Change
Arizona State University

voice: 480-965-6262 (SHESC), 480-965-8130/727-9746 (CSDC)
fax: 480-965-7671 (SHESC), 480-727-0709 (CSDC)
www: http://www.public.asu.edu/~cmbarton, http://csdc.asu.edu

On Sep 15, 2013, at 1:42 PM, Moritz Lennert <mlennert@club.worldonline.be>
wrote:

On 14/09/13 21:01, Michael Barton wrote:

Moritz,

This is a nice addition.

Actually, not that nice. I just reread one of the papers you give as reference [1] and it clearly states that the equation that you use for estimating the expected mean nearest neighbor distance "cannot be used for irregularly shaped study areas"...

Thanks, I'm really swamped right now. Do you want to add it to the script and add your name to the authors?

I'll see what else I can find in the literature about how to calculate the expected mean distance to see if having the actual study area measures is really useful. If yes, I'll add the patch myself.

BTW, shouldn't the scripts v.nn.py and v.lda.py go into the addons svn ? If you agree then I can add them there, with or without my patch. I've also locally modified v.lda.py a bit to allow easier (to me at least) use of the results.

Moritz

[1] http://www.geog.ucsb.edu/~dongmei/ppa/ppa.html

Michael Barton
School of Human Evolution&Social Change
Center for Social Dynamics& Complexity
Arizona State University

...Sent from my iPad

On Sep 14, 2013, at 9:11 AM, "Moritz Lennert"<mlennert@club.worldonline.be> wrote:

Michael,

I've attached a patch to your very useful v.nn.py addon script. The patch provides the following:

- a change of option names from input1,2 to 'from' and 'to'
- the possibility to provide a vector map with polygons giving the contours of the study area for which to calculate the nearest neighbor coefficient - the script just gets the total of all areas and all perimeters in the given map
- the possibility to provide numerical values for area and perimeter

Even though some people argue that the absolute value of the coefficient does not mean much and that the exact size of the study area does not have an influence on the relative values of the coefficient, I think it is a plus to have the possibility to circumscribe the area. Especially since in its current state the module gets the area and perimenter from the current region and as this is a vector module most people won't even think about region settings. (Running the module in the default n=1 s=0 w=0 e=1 region gives very weird coefficient values.

Up to you to decide whether you want to add this into your script.

BTW: the script works perfectly in grass7 as well.

Moritz
<v.nn.py.diff>