[GRASS-dev] Re: [GRASS-user] points in polygon query

Here a try but something is still missing:

# Spearfish
# Task: count number of archaeological sites per field

g.copy vect=fields,myfields
# fetch field IDs:
v.category myfields layer=2 out=myfields2 op=add type=centroid
# prepare numer of points per polygon column:
v.db.addtable myfields2 layer=2 col="ptsnum integer"
v.info -c myfields2 layer=2

g.copy vect=archsites,myarchsites
# prepare and fetch polygon numbers each archsite falls into:
v.db.addcol myarchsites col="polynum integer"
v.what.vect myarchsites qvector=myfields2 qcol=cat qlayer=2 col=polynum
d.vect myarchsites disp=shape,cat lcol=blue
v.db.select myarchsites

# so far, so nice

# Approach 1:
v.what.vect myfields2 layer=2 col=ptsnum qvector=myarchsites qcol="count(polynum)"
# -> count() doesn't exist!

# Approach 2:
v.to.db myfields2 option=query layer=2 qlayer=1 [qvector=myarchsites] column=ptsnum qcolumn="count(*)"
# -> we cannot query the myarchsites here! qvector missing

Close but not yet. More ideas welcome...
Markus

On Fri, May 18, 2007 at 12:14:35PM -0400, M S wrote:

   cant you have a polygon coverage with an attribute in it "PolyNum" with
   unique IDs, and then do a v.overlay with the points and polys so the
   points get the PolyNum attribute?

   then run reports and summaries on the counts in each PolyNum. maybe I
   misunderstand the question.

   Mark

   On 5/18/07, Markus Neteler <[1]neteler@itc.it> wrote:

     Hi,

     someone asked me today a similar question as expressed by Maximiliano,
     still
     no idea how to calculate this in an elegant way.
     Any suggestions how to count the number of points falling into polygons
     of another map?

     Markus

     Massimiliano Cannata wrote:
     >
     > Hi all,
     > I have a task to accomlpish but I don't know how to perform it...
     > Maybe someone can give me some hinits.... :slight_smile:
     >
     > I have a points layer and a polygon layer.
     > I want to generate a map with the geometry of the polygons and an
     > attribute that is the count of the points that fall inside.
     >
     > Example:
     > polygons: Municipalities
     > points: car accidents
     > resulting map: Municipalities represented for number of car accidents
     >
     > Thanks you all,
     > Maxi
     >
     > --
     > Dr. Eng. Massimiliano Cannata
     > Scuola Universitaria Professionale della Svizzera Italiana
     > Istituto Scienze della Terra
     > Via Trevano, c.p. 72
     > CH-6952 Canobbio-Lugano
     > Tel: +41 (0)58 666 62 14
     > Fax +41 (0)58 666 62 09
     >

     --
     View this message in context:
     [2]http://www.nabble.com/-GRASS-user--points-in-polygon-query-tf2066000.html#a10684819
     Sent from the Grass - Users mailing list archive at [3]Nabble.com.

     _______________________________________________
     grassuser mailing list
     [4]grassuser@grass.itc.it
     [5]http://grass.itc.it/mailman/listinfo/grassuser

References

   Visible links
   1. mailto:neteler@itc.it
   2. http://www.nabble.com/-GRASS-user--points-in-polygon-query-tf2066000.html#a10684819
   3. http://nabble.com/
   4. mailto:grassuser@grass.itc.it
   5. http://grass.itc.it/mailman/listinfo/grassuser

--
Markus Neteler <neteler itc it> http://mpa.itc.it/markus/
FBK-irst - Centro per la Ricerca Scientifica e Tecnologica
MPBA - Predictive Models for Biol. & Environ. Data Analysis
Via Sommarive, 18 - 38050 Povo (Trento), Italy