Find multiple points in same position

From GRASS-Wiki
Jump to: navigation, search

Find multiple points in same position (remove duplicates)

... applies to GPS observations, Lidar etc.

Procedure 1

As example, we generate 3 points in the same place.

# Generate 3 points in the same place (Spearfish60):
echo "599505|4921010|1
599505|4921010|3" | 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" -c triple_simple_multi layer=2 triple_simple_multi
3|599505|4921010|3 triple_simple_multi layer=2

# upload number of identical vector points to attribute table:
# (no DBF driver) triple_simple_multi option=query layer=2 qlayer=1 column=count qcolumn="count(*)" triple_simple_multi layer=2

# print number of points in map:
d.vect triple_simple_multi layer=2 disp=attr attrcol=count

Procedure 2

Use v.generalize

v.generalize input=in output=out method=reduction threshold=0

removes duplicate points. More precisely, if two consecutive points have the same coordinates then the second point is removed and the first is preserved. The last two algorithm implemented by this module are "Lang" and "Reumann-Witkam" algorithm. For more information about these two algorithms, please see the v.generalize man page.