I'm trying to join touching lines within a linestring dataset, so that I end up with a single feature for each set of touching features (eg the set outlined in green below). I've tried pretty much every algorithm I can find, including dissolve, merge, union (in QGIS, including the GDAL and SAGA options), ST_LineMerge in PostGIS, but the lines refuse to join, even though the end nodes of the segments are coincident. Can anyone suggest a process which would do this? I'm running this as part of a processing model in QGIS which has several hundred thousand records, so it needs to be a process I can include in this.
I can manually merge the features into one using the 'merge selected features' tool, but I can't see how to run this as a process, and even so, running 'split with lines' on the result splits the lines as they were initially, resulting in four features not three.
My guess is that there is something about the data which is causing this, but I can't see a way of fixing it, or running the merge.