1

I'm looking to accomplish a similar task to this thread: Splitting line at point positions using QGIS?

Using QGIS and the Processing and GRASS toolboxes available, I'm looking to split a vector layer representing a hydrolic network at points which represent junctions. I've been told v.distance exists in Processing as well, but I can't access it. Using GRASS v.distance, I get the error notice that not enough columns are available.

  • Thanks markusN and @Micha. I'm fairly new to QGIS and GRASS. Though I was originally tempted to follow the Arc path, i'm grateful for your suggestions using the latter. Only issue is i can't seem to find the v.edit tool in either the GRASS toolsbox or the Processing toolbox using QGIS 2.0. Is there a module to be imported? Also, v.distance has recently caused me problems using another dataset... – user25976 Feb 7 '14 at 17:37
  • Welcome to GIS SE! One thing to note is that when you have additional information/clarification to make to your Question it is better to use the edit button to revise it rather than by tacking on Comments. – PolyGeo Feb 25 '14 at 21:42
2

When importing a line vector into GRASS, the topology cleaning automatically splits lines at every intersection. If you need to split lines at additional points, you can use

v.edit

The tool=break is what you need, and the "coords" parameter is for the X-Y of the point to split. If you have the coordinates of all your "junctions" then feed those in a loop into the v.edit command. You might do this by dumping the X-Y coordinates of the junctions into a text file with v.out.ascii. Then read the text file, line by line, in a bash loop, something like:

v.out.ascii junctions separator=" " out=junction_coords.txt
while read x y cat; do \
v.edit map=hydro_network tool=break coords=$x,$y; \
done < junction_coords.txt

BTW, if the junction points are not exactly on the line, you will want to look into the combination of:

v.distance
v.patch
v.clean

This procedure creates small connector lines from the jucntion points to the hydro_network, then by patching these connectors to the network, and running v.clean, you get an "error" output point vector which is the intersection points of each connector and the original hydro_network. THis way you can get a new set of "snapped" junction points which fall exactly on the hydro_network.

  • is the loop to be run through the GRASS command console? – user25976 Mar 25 '14 at 20:17
  • Yes, run the loop in a GRASS session – Micha Mar 26 '14 at 8:52
  • 'while read x y cat;' doesn't appear to be possible in the GRASS command console as ';' is inaccessible. 'while read x y cat' throws an error using the GRASS command console. Possible to run loop through v.edit dialog window if XY coordinates already dumped via v.out.ascii? – user25976 Mar 27 '14 at 0:09
  • I was assuming a bash shell. If you are on a different operating system, you'll have to use whatever looping is available in that system. – Micha Mar 27 '14 at 6:34
  • @Micha can we use v.distance to get the nearest coordinates on the to_line and use these coordinates as input of v.edit? If this works, then we don't need to use v.patch and v.clean module! – Heinz Jun 10 '14 at 3:42
0

In GRASS GIS, use v.edit. The manual page contains an example on "Split line on given point".

  • I saw the manual page of the splitting example, "v.edit map=roads tool=break coords=604268,4923570 id=810 thresh=50". It seems that I can use points not on the line to split the line? If I don't know the exact id of the line segment I want to split, can v.edit work if I don't assign ids to it? – Heinz Jun 10 '14 at 3:50
0

v.net does this also very nice with the "connect" option. Note that after connecting the points to the lines, you would have to run v.category to add IDs to the new line segments (as described in the manual).

-1

The ArcGIS for Desktop Advanced Split Line at Point tool which

Splits line features based on intersection or proximity to point features.

will do this.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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