I have a polygon layer I want to explode into single lines. I preferably wish to do so in spatialite since I work almost exclusively in QGIS DB-manager. No matter which function I use the number of features stays the same:



Now there is also that concept of ElementaryGeometries which is spatialite specific and does not seem to be implemented in geopackage or QGIS virtual layers (please correct me if I am wrong here). Also there's this answer that I honestly fail to follow due to sparse documentation as well as on whether this is implemented in QGIS' DB-manager environment or not.

I know there's a bunch of native tools that do the job but I'd really love to keep my workflow streamlined and avoid intermediate result layer as much as possible.

  • 2
    I don't think it is easily possible (yet), and you may have to rely on using a geoprocessing tool instead of a virtual layer. There is a way to achieve it using recursive queries, have a look at this post
    – JGH
    Dec 10, 2021 at 21:49
  • TY, bookmarked. Morbidly fascinating. Successfully tested, adoption for exploding lines pending.
    – maxwhere
    Dec 10, 2021 at 22:13
  • Maybe the ST_Dump() function helps postgis.net/docs/ST_Dump.html
    – jpinilla
    Dec 11, 2021 at 9:49
  • 1
    ST_Dump does not work for spatialite/Virtual Layer at this point. I agree, CTE/recursive queries seem to be the only way forward for now. See gis.stackexchange.com/a/341570/98784 for another example
    – she_weeds
    Dec 14, 2021 at 1:10


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.