I have a layer representing hydraulic network and I would like to merge the lines when they are connected to each other at their start/end vertex.
In the picture below , I merged the lines manually by selecting the lines and using the tool 'Merge selected feature'
. I would like to generalise the process to integrate it in a model builder.
I tried using 'Dissolve'
then 'Multipart to singlepart'
but this is not working. When lines have multiple branches, each of them becomes a new feature after splitting to singlepart (as in the picture in this thread)
I also tried using a 'Buffer'
(with dissolve option activated) and then 'Joining by location'
the lines within the buffer. This work for the lines in blue in the picture, however it doesn't work for the green and orange one because the dissolved buffer is joined where the green and orange lines are overlapping.
I tried to create a dissolved buffer that would except when lines overlap but no success.
I am working with QGIS 3.16.3