[GRASS5] counting number of vector points in same position?

Markus Neteler neteler at itc.it
Tue Aug 16 16:38:14 EDT 2005


Radim,

thanks for your example. I took the occasion to write the scripts:

  v.db.addtable help
    adds a new attribute table to a given layer of a vector map

and
  v.db.droptable help
    removes existing attribute table of a vector map


Trying to make an example out of below sketch, I finally failed:

# Generate 3 points in the same place (Spearfish60):
echo "599505|4921010|1
599505|4921010|2
599505|4921010|3" | v.in.ascii out=triple

# remove duplicates from map:
v.clean triple out=triple_simple tool=rmdupl
# ... remaining: one2many link between geometry and attributes

# verify categories:
v.category triple_simple op=report
LAYER/TABLE 1/triple_simple:
type       count        min        max
point          3          1          3
line           0          0          0
boundary       0          0          0
centroid       0          0          0
area           0          0          0
all            3          1          3

# add new layer with 1 cat/point:
v.category triple_simple out=triple_simple_multi layer=2

# create and link new table to layer 2:
v.db.addtable triple_simple_multi layer=2 columns="cat integer, count integer"
v.info -c triple_simple_multi layer=2

# upload number of identical vector points to attribute table:
v.to.db triple_simple_multi option=query layer=2 qlayer=1 column=count
Reading data trom the map ...  100%
Querying database ...  100%
DBMI-DBF driver error:
SQL parser error in statement:
SELECT (null) FROM triple_simple_multi WHERE cat = 2 OR cat = 1 OR cat = 3
Error in db_open_select_cursor()

ERROR: Cannot open cursor: 'SELECT (null) FROM triple_simple_multi WHERE
        cat = 2 OR cat = 1 OR cat = 3'


Perhaps you can identify the mistake in the procedure.

Thanks

 Markus


On Tue, Aug 16, 2005 at 10:36:23AM +0200, Radim Blazek wrote:
> 1) v.clean rmdupl will remove duplicates and it should attache 
>     all cats to one point (-> one-many link between geometry and attributes)
> 2) v.category layer=2 (-> new layer with 1 cat/point)
> 3) create and link new table to layer 2
> 4) v.to.db option=query layer=2 qlayer=1 
>     (query attributes in layer 1 and uppload to layer 2)
> 
> Radim
> 
> On 8/10/05, Markus Neteler <neteler at itc.it> wrote:
> > Hi,
> > 
> > I have to transform a vector points map of disease reports.
> > Often more than one report falls into the same location as
> > reports were done/geocoded based on cities. This results into
> > a vector map with often several vector falling into the
> > same coodinate pair.
> > 
> > I have to transform this map into a new vector map with
> > single point per coordinate pair and number of cases as
> > attribute.
> > 
> > How to do that?
> > 
> > I was thinking of v.distance -a to calculate zero-distances.
> > This requires to exclude that the points "see" themselves.
> > But then, I am not sure how to transform this into a map.
> > Maybe with some SQL fun (distinct() operator or so)?
> > 
> > Suggestions welcome. This functionality appears to me to
> > be needed for GRASS. I darkly remember that it was asked
> > time ago, but cannot find the mail(s).
> > 
> > Thanks
> > 
> >  Markus
> > 
> > _______________________________________________
> > grass5 mailing list
> > grass5 at grass.itc.it
> > http://grass.itc.it/mailman/listinfo/grass5
> >
> 
> 
> 

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




More information about the grass-dev mailing list