[GIS] Splitting polylines according to coincident (or touching) points with other polylines

arcgis-desktopcoincidentlineqgis

The question is unfortunately not answered yet.

I'm looking for a method or python script to split polylines according to coincident points with other polylines, but avoid splitting the ones which just intersect (without a sharing point like the planarize or intersection tool in ArcGIS would produce). The "touches (second_geometry)" function might be a way but I have at the moment no clue how to solve it.

The image illustrates my aim. The yellow line hasn't changed, because it has no coincicent points with the red line. While the red line as well as the dark blue line is split into 4 different polylines, because both share a coincident point.
enter image description here

Thanks for any answer in advance!

Best Answer

Here is a solution for ArcGIS, you can use the code in your Python Window. Of course after adapting it to your paths and names. (and yes, the code is not very beautifully written)

1. I took the lines and converted them to Points.

2. I run the Near funktion with the Points as "From" and as "To" data. This function returns the distance to the nearest feature. If you use the same data as "From" and "To" it will ignore calculating distances to itsself and take the second nearest feature. If the distance to the second nearest Point is 0 we can conclude there are two points (=vertices in the original) at this Point.

3. Than I selected this Points with "NEAR_DIST" = 0 and

4. cut our Polyline there.

import arcpy

arcpy.FeatureVerticesToPoints_management("D:/Test.shp","D:/TestP.shp","ALL")
arcpy.Near_analysis("D:/TestP.shp","D:/TestP.shp","#","NO_LOCATION","NO_ANGLE")
arcpy.Select_analysis("D:/TestP.shp","D:/TestSel.shp","""\"NEAR_DIST\" = 0""")
arcpy.SplitLineAtPoint_management("D:/Test.shp","D:/TestSel.shp","D:/Result.shp","1 Meters")
Related Question