Find multiple points in same position

From GRASS-Wiki
Jump to navigation Jump to 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|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
v.db.select triple_simple_multi
cat|int_1|int_2|int_3
1|599505|4921010|1
2|599505|4921010|2
3|599505|4921010|3
v.db.select triple_simple_multi layer=2
cat|count
1|

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

# 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.