Vector break line intersections
Jump to navigation
Jump to search
Example of breaking a vector line at intersections
Q: I have a vector line map (river network) which I want to clean and break the lines at intersections. How to manage the categories?
A: Using GRASS v.clean tool:
# Cleaning vector and breaking lines v.clean -c --overwrite input=river_network_modified output=river_network_modified_clean tool=break,snap,rmline threshold=0,50,0 # Check cats v.category input=river_network_modified_clean option=report layer=-1
Now add new categories to a new layer, e.g. with
v.category option=add layer=2 cat=1 step=1 type=line ...
Then add a new table to layer 2
v.db.addtable layer=2 columns="cat_lyr1 integer" ...
Load category values (or any other attributes) from layer 1 to layer 2 with
v.to.db layer=2 column=cat_lyr1 query_layer=1 query_column=cat ...
Now you have unique new categories in layer 2 and the old categories still existing in layer 1 are also in the field cat_lyr1 of layer 2.