Re: [GRASS-user] polygons and centroids redux

2010-06-12 Thread Dave Roberts

Thanks Hamish.  It seems only likely that such a routine would exist.

Here's the part where I need a little help though.  It appears that

v.distance from=pnt to=area dmax=0 upload=cat column=areacat

will find and report the cat number of the polygon that points lie 
within, and I can use that in a database operation which is extremely 
handy.  So, I have done that, and now the area cat for each point is 
available in the database.  That works for points in a point vector 
feature.


Using d.what.vect or v.what, however, I cannot control whether the 
function reports a boundary or centroid.  This makes it hard to

replicate the behavior of v.distance for a few points on the fly.
Is there some way to access the existing point-in-polygon routine from 
an existing GRASS function to simulate what I'm after?


Looking at the progammer's manual, writing something like v.pip (= to 
d.what.vect reporting always area cat) appears to be a bit more than I 
want to bite off at present.


Perhaps one approach would be

d.where  file
(edit file as necessary for separator)
v.in.ascii in=file out=points fs=whatever
v.distance from=points to=area dmax=0 upload=cat column=areacat

That works but seems like a lot of work for what I'm after.

Thanks much, Dave


Hamish wrote:

Dave wrote:

I think it would indeed be handy if a switch
was added to v.what and
d.what.vect in GRASS 7.  In the meantime it might be
handy to write a v.pip command for GRASS 6.  I have
written a point-in-polygon routine for other software
(including R), but I would have to really study the file
structures of GRASS vectors to attempt that in
GRASS.   If any GRASS programmers are
interested let me know and perhaps we could work it out as
an add-on.


point in polygon is a standard function in the vector library for
years.


Hamish


  


___
grass-user mailing list
grass-user@lists.osgeo.org
http://lists.osgeo.org/mailman/listinfo/grass-user


[GRASS-user] polygons and centroids

2010-06-11 Thread Dave Roberts

Friends,

   If I understand correctly (based on experience with my own data), 
when GRASS calculates the topology for vector area data it doesn't 
actually ensure that the centroid lies within the area it represents. 
If the area is a torus, or at least hollow in a general way, then the 
centroid might actually lie in the void in the center of the polygon 
rather than within the interior of the polygon itself.  It seems like
it would be preferable to run a point-in-polygon check on the calculated 
centroid and move it of necessary to achieve correct point-in-polygon 
correspondence.


   This seems like it may also influence the results of v.what and 
d.what.vect as well, and not always identify the correct polygon if 
another centroid is nearer.  I assume this is a well-known situation, 
and that perhaps the solution for complex (sometimes hollow) polygons 
(following advice from Achim Kesseler)is to do a v.to.rast and sample 
the raster.   Is that considered best practice for complex area data, or 
are there better approaches?  Is v.what reliable in these situations, 
including in point-in-polygon mode?


Thanks, Dave
--

David W. Roberts office 406-994-4548
Department of Ecology email drobe...@montana.edu
Montana State University
Bozeman, MT 59717-3460
___
grass-user mailing list
grass-user@lists.osgeo.org
http://lists.osgeo.org/mailman/listinfo/grass-user


Re: [GRASS-user] polygons and centroids

2010-06-11 Thread Markus Metz
Dave Roberts wrote:
 Friends,

   If I understand correctly (based on experience with my own data), when
 GRASS calculates the topology for vector area data it doesn't actually
 ensure that the centroid lies within the area it represents. If the area is
 a torus, or at least hollow in a general way, then the centroid might
 actually lie in the void in the center of the polygon rather than within the
 interior of the polygon itself.

No, grass does ensure that a centroid lies within an area when
building topology (attaching centroids). After building full topology,
the number of centroids outside any area is reported as
Number of centroids outside area:

Markus M
___
grass-user mailing list
grass-user@lists.osgeo.org
http://lists.osgeo.org/mailman/listinfo/grass-user


[GRASS-user] polygons and centroids redux

2010-06-11 Thread Dave Roberts

Friends,

 This is the second time in two days I have had to post an apology 
and retraction for hasty questions.  I apologize for testing everyone's 
patience.  Thanks Markus; I was composing this message when I saw your 
post.  I mistook a centroid of a polygon too small to plot at the 
current resolution as the centroid of the surrounding hollow area.  My 
mistake; sorry.


It does raise a question, however, of what the conditions are that 
cause d.what.vect to return a feature type of Boundary rather than 
Area when querying a map.  Is it simply proximity to the boundary, and 
can that behavior be suppressed in preference to always returning the 
data associated with the centroid?


Thanks, Dave
--

David W. Roberts office 406-994-4548
Department of Ecology email drobe...@montana.edu
Montana State University
Bozeman, MT 59717-3460
___
grass-user mailing list
grass-user@lists.osgeo.org
http://lists.osgeo.org/mailman/listinfo/grass-user


Re: [GRASS-user] polygons and centroids redux

2010-06-11 Thread Markus Metz
Dave Roberts wrote:

    It does raise a question, however, of what the conditions are that cause
 d.what.vect to return a feature type of Boundary rather than Area when
 querying a map.

d.what.vect and v.what search for points and centroids first. If none
is found, they continue and search for lines, boundaries and faces. If
none is found, they continue and search for areas. This search order
causes any centroid or boundary to be returned if found, and not the
corresponding area. Currently there is no way to select the feature
type (point, centroid, line, boundary, area, face) to be searched.
This option could be added for v.what in 7.0 if desired.

Markus M
___
grass-user mailing list
grass-user@lists.osgeo.org
http://lists.osgeo.org/mailman/listinfo/grass-user


Re: [GRASS-user] polygons and centroids redux

2010-06-11 Thread Dave Roberts

Thanks Markus!

I think it would indeed be handy if a switch was added to v.what and
d.what.vect in GRASS 7.  In the meantime it might be handy to write a 
v.pip command for GRASS 6.  I have written a point-in-polygon routine 
for other software (including R), but I would have to really study the 
file structures of GRASS vectors to attempt that in GRASS.   If any 
GRASS programmers are interested let me know and perhaps we could work 
it out as an add-on.


Thanks, Dave R


Markus Metz wrote:

Dave Roberts wrote:

   It does raise a question, however, of what the conditions are that cause
d.what.vect to return a feature type of Boundary rather than Area when
querying a map.


d.what.vect and v.what search for points and centroids first. If none
is found, they continue and search for lines, boundaries and faces. If
none is found, they continue and search for areas. This search order
causes any centroid or boundary to be returned if found, and not the
corresponding area. Currently there is no way to select the feature
type (point, centroid, line, boundary, area, face) to be searched.
This option could be added for v.what in 7.0 if desired.

Markus M


___
grass-user mailing list
grass-user@lists.osgeo.org
http://lists.osgeo.org/mailman/listinfo/grass-user


Re: [GRASS-user] polygons and centroids redux

2010-06-11 Thread Hamish
Dave wrote:
     I think it would indeed be handy if a switch
 was added to v.what and
 d.what.vect in GRASS 7.  In the meantime it might be
 handy to write a v.pip command for GRASS 6.  I have
 written a point-in-polygon routine for other software
 (including R), but I would have to really study the file
 structures of GRASS vectors to attempt that in
 GRASS.   If any GRASS programmers are
 interested let me know and perhaps we could work it out as
 an add-on.

point in polygon is a standard function in the vector library for
years.


Hamish



___
grass-user mailing list
grass-user@lists.osgeo.org
http://lists.osgeo.org/mailman/listinfo/grass-user