3

If have an input layer with a couple of lines, called Line with an attribute. I would like to have a virtual layer with alle connecting lines dissolved, regardless of the attribute.

input:

enter image description here

expected output as in "dissolve" with keep disjoint features separate

enter image description here

I used the following query: select ST_LineMerge(geometry) as geometry from Line But the connected lines are not merged:

enter image description here

Using ST_Union in the following query yields me a single multipart feature: select st_multi(st_union((geometry))) as geometry from Line

enter image description here

could the Group bysegment with something like Disjoint be an option? Like

select st_multi(st_union((geometry))) as geometry from Line
Group By disjoint
Beni
  • 358
  • 1
  • 8
  • If you happen to have Postgis, it is much easier to do via a spatial cluster. – JGH Nov 17 '23 at 14:18
  • 1
    Hard, if not impossible, via a virtual layer. See this similar post. There is no clustering function to detect all touching geometries, and it is almost impossible to extract individual geometries from a multigeometry (still technically feasible, with the use of recursive functions... honestly, it's not worth the effort) – JGH Nov 17 '23 at 14:20
  • many thanks! But would the application of ST_LineMerge(geometry) be correct in this case? – Beni Nov 17 '23 at 15:55
  • 2
    It depends what you want to do... st_lineMerge requires a multiline and will try to stitch segments together. So maybe you could create one giant multiline, st_lineMerge it and explode it again (but not in a VL) – JGH Nov 17 '23 at 16:14
  • It depends of your geometries, they should merge with ST_LineMerge if they really touch, if they don't that means they don't really touch. You can fix them with functions like ST_SnapToGrid, or merge cluster of lines close enough with cluster done with ST_ClusterDBSCAN for example. – robin loche Nov 24 '23 at 12:48

0 Answers0