2

I have a line layer and a point layer and need to split the lines with the points:

enter image description here

I tried to use the Split Lines at Points- Tool from SAGA, but it doesn't split at every point, but seems to randomly let out some points. I tried it multiple times, but it didn't work.

Weirdly, it seems the points are not intersecting with the lines, even though they are created with 'Points along Geometry' on that line geometry. But when I use 'Select by location' only a few points are selected which intersect with the lines.

Another approach was, to first snapping the points to the lines, but also after that, not more points are selected when I use select by intersection.

Both layer have the same CRS and the Points are even created from the Line layer, so how can they not intersect?

Every further suggestion to split the lines with the points is very, very welcome!

i.i.k.
  • 1,427
  • 5
  • 11
  • 1
    Try using ST_SnapToGrid for both lines and points. Points which are computed by different algorithms (here first Points along geometry and then the algorithm that splits the geometries) may differ somewhere beyond the seventh decimal place or so. – user30184 Aug 28 '23 at 12:08
  • Mh, how do I use this tool? I cannot find it in QGIS. The only tool I find is 'Snap point to grid', bu tthere is non for line geometries. Can you explain how to use that tool? – i.i.k. Aug 28 '23 at 12:18
  • 1
    Sorry, I forgot that all people do not use PostGIS https://postgis.net/docs/en/ST_SnapToGrid.html. The QGIS tool Snap points to grid seems to be doing the same thing "This algorithm modifies the coordinates of geometries in a vector layer, so that all points or vertices are snapped to the closest point of the grid." Snap points or vertices to grid could be a better name for the tool, but maybe it is too long. But I fear that Points along geometry is not the right tool. If creates a new point layer, but to be reliable for your use case it should add new vertices to the line geometry. – user30184 Aug 28 '23 at 12:35
  • I would like to use PostGIS with QGIS but I didn't manage to set it up. But I must also admit: the pressure to actually use it wasn't high enough so far ;) Until now I work with QGIS and Python. – i.i.k. Aug 28 '23 at 12:49
  • You can find Snap Points to Grid if you press Ctrl+Alt+H and search – BERA Aug 29 '23 at 05:34
  • You can also try https://gis.stackexchange.com/a/474125/107424 – MrXsquared Mar 04 '24 at 16:42

1 Answers1

4

I managed to split the lines at the coordinates of the points by 1. calculating the angle of the points, 2. create small lines of the points with a perpendicular angle and 3. split the lines with the created lines. In detail:

1.First use the "Explode lines" tool on the relevant line-layer, yielding all line segments, then calculate azimuth with the Field Calculator for each line segment:

degrees(azimuth(start_point($geometry), end_point($geometry)))
  1. Join the azimuth field from the line layer to the point layer using 'Join by nearest'

  2. use the 'Geometry by expression' tool, select the points to split and use the just calculated azimuth field in the expression:

make_line(project($geometry, 50, radians("azimuth"+90)), project($geometry, 50, radians("azimuth"+270)))

This will result in 100m long perpendicular lines for each point: enter image description here

  1. Use the 'Split lines with lines'-Tool.
i.i.k.
  • 1,427
  • 5
  • 11