[GRASS-user] How to split a line using points?

Vincent Bain bain at toraval.fr
Thu Jun 14 10:40:02 PDT 2012


A brief suggestion, just ideas to feed your inspiration ;-)

I would try to combine v.edit (tool=break) with a set of short lines
created from your "fromnodes" map : we need to retrieve points
coordinates, hoping they are quite coincident with lines vertices of
your "fromlines" map, and create straight vector lines, each with :
	* from-node=break-node 
	* to-node=break-node-translated-a-short-distance.

Here's how I would proceed :

v.out.ascii on fromnodes map. It will create a file looking like this
for each feature :

P  1 1
 594125.63    4921115.58
 1     1

then you can turn it (through a script for the huge number of points you
deal with) into :

L  2 1
 594125.63    4921115.58
 594125.63    4921116.58
 1     1

(in this example the short line is pointing 1 m towards north from the
initial point)

Then put back these lines in a "cuts" line map (v.in.ascii).

Run v.edit to make sure frompoints and lines vertices match :

v.edit map=cuts type=line tool=move move=0,0 thresh=-1,<reasonable snap
distance>,0 where="<a statement selecting all lines>" bgmap=fromlines
snap=node

Finally run again v.edit to break lines at intersections (didn't check
if bgmap applies to break tool, you need to check) :

v.edit map=fromlines type=line tool=break where="<a statement selecting
all lines>" bgmap=cuts

Good luck!

Vincent





More information about the grass-user mailing list