How do I get for each v.to.points
point an ID in the database (DB).
So far I splited the line (each 10m) but it returns only one DB entry for each original line.
v.db.select line
cat|Id|Name
1|1|Line 1
2|2|Line 2
# split the lines every 10m
v.to.points in=line out=line_points dmax=10
# check the result
v.db.select line_points
cat|Id|Name
1|1|Line 1
2|2|Line 2
Each point should have its own DB entry. The result should be:
v.db.select line_points
cat|Id|Name
1|1|Line 1
2|1|Line 1
3|2|Line 2
4|2|Line 2
Workaround: So far my workaround is, to export (v.out.ogr
) the points as shape and import (v.in.ogr
) it again. Then each point has his own ID. But there must be a smarter way to do that!
Answer
v.to.points
creates a vector with 2 layers. With the second layer you should have unique ID.
You should thus simply specify the second layer with v.db.select
or write into a new feature with v.category
.
# return unique IDs
v.db.select line_points layer=2
# change layer 2 to 1
v.category input=line_points output=line_points2 option=chlayer layer=2,1
For more details see v.to.points
description:
v.to.points
creates points along input lines. The output is a vector with 2 layers. Layer 1 holds the category and attributes of the input lines; all points created along the same line have the same category, equal to the category of that line. In layer 2 each point has it's unique category; other attributes stored in layer 2 are lcat - the category of the input line and along - the distance from line's start.
No comments:
Post a Comment