[GRASS-user] polygons and centroids redux
Dave Roberts
dvrbts at ecology.msu.montana.edu
Sat Jun 12 11:45:43 EDT 2010
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
>
>
>
>
More information about the grass-user
mailing list