[GRASS-user] Vector map attributes
Craig Leat
craig.leat at gmail.com
Wed Mar 25 06:05:13 EDT 2009
Hello
I have a vector map with points representing latrines and each point
has an attribute describing the place name. I ran v.edit to snap
points with a threshold of 5m and v.info reports 7296 features for the
cleaned map. I now wish to count the number of latrines in each place,
so I ran:
> echo "SELECT *,count(Area) FROM MT_San_clean GROUP BY Area" | db.select
and get a total of 10537, so the results are bogus.
Running the following command I can see the reason for the bogus results:
> v.category in=MT_San_clean opt=print
1331/566/571/691/1332/456/416/410/405/561/390
1294/1249/1265/1229/1225/1273/1233
v.edit has assigned multiple categories to points when they were snapped.
To get a meaningful count of points by Area I can think of two solutions:
1) Use awk to filter out the first category for each feature from the
output of v.category opt=print and feed this list of cats into
db.select,
however I'm not sure of the sql syntax for WHERE "cat=MyListOfCats".
2) Use awk to filter out all, but the first category for each feature
from the output of v.category opt=print and feed this list of cats
into v.category opt=del,
however I'm not sure of the relationship between feature ids and cats,
and v.category wants a list of ids.
Can someone please suggest an easier way or give me a pointer to
implement either of my ideas? As a teaser I can offer to update [1]
with the details :-)
Many thanks,
Craig
[1] http://grass.osgeo.org/wiki/Count_points_in_polygon
More information about the grass-user
mailing list