2

I have a point layer and a line layer (old). I projected my points to the closest line of the line layer. For it I used geometry expression

shortest_line(
    @geometry, 
        aggregate('old_line', 'collect', @geometry)
)

So I got two line layer. Now I try to split old line layer by lines from the new layer. I used a tool described here Split Lines at Intersection of Other Lines but it didn't help me. I also tried to union both vector layer and then to use Explode lines. But line wasn't splitted. Could anybody help me? I need two lines instead this yellow line: enter image description here

At the same time another line was splitted. I don't understand what the difference because the points were projected to the closest line with the same expression enter image description here

MrXsquared
  • 34,292
  • 21
  • 67
  • 117
redhat
  • 347
  • 6
  • I assume it is because your lines to not cross the other lines in most cases, they just touch (or eventually not even that). That they sometimes do may be due to coordinate precision. You could extend your lines a little and try if it will work then. Also take a look at https://gis.stackexchange.com/questions/184191/splitting-line-layer-using-another-point-layer-in-qgis – MrXsquared Feb 02 '24 at 19:10
  • How could I extend a line? I'm new in QGIS and I don't know. – redhat Feb 02 '24 at 19:18

1 Answers1

3

I assume it is because your lines to not actually cross the other lines in most cases, they just touch (or eventually not even that). That they sometimes do touch/cross / do not touch/cross may be due to coordinate precision. You could extend your lines a little and try if it will work then.

extend( 
    shortest_line(
        @geometry, 
            aggregate('l', 'collect', @geometry)
    )
,0,1) --extend start: 0 crs units, extend end: 1 crs unit
MrXsquared
  • 34,292
  • 21
  • 67
  • 117