8

I have a polyline and I have two points on the polyline.

I would like to know if there is a tool or script that I could use to split my original polyline into 3 polylines? (Starting point to point A, Point A to B and B to ending point of the polyline)?

I am looking for an automatic process rather splitting the line manually.

1
  • how do you decide where B is? You might want to google LRS GRASS (linear referencing system) and see if that is the same concept.
    – Willy
    Jul 28, 2012 at 12:08

3 Answers 3

2

QGIS won't do this natively to the best of my knowledge. However, you can use GRASS from within QGIS, and this thread looks like exactly what you want. I haven't tested this, but it all makes sense. Credit of course goes to the folks in that thread. First, you would import your data into GRASS then:

dump the coordinates to a text file (v.out.ascii) then loop thru that file, and feed the coords to v.edit, like so: v.out.ascii out=points.txt while read x y; do v.edit tool=break coord=$x,$y cat=0-99999 done < points.txt

Note the caveat that your points must be exactly on the line.

Or, even simpler in a bash environment:

v.out.ascii format=point in=pts --q | cut -d'|' -f1,2 | tr '|' ',' | while read COOR; do v.edit map=line tool=break coords=$COOR; done

1
  • Can you simplified it. I am first timer ON grass. Aug 19, 2015 at 9:05
1

If qgis cannot do that, shapely (a python module for manipulating shapefiles) seems able to do what you want.

Check http://sgillies.net/blog/1040/shapely-recipes/

To install the module, from you command terminal type: $ sudo pip install shapely

2
  • Clarification: Shapely is an interface to GEOS and does computational geometry. It doesn't know anything about shapefiles.
    – sgillies
    Sep 4, 2012 at 15:16
  • 1
    link doesnt work anymore
    – radouxju
    Sep 28, 2018 at 12:35
0

I just used GRASS module v.net.connect to carry out this task. Pay attention to distances points are away from lines (required input). Import lines and points to GRASS, find the v.net module, select the 'connect' option and set necessary parameters. I'm an amateur with GRASS and managed to get it done - getting GRASS and QGIS to work was the biggest hurdle!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.