2

I have a spatialite table with more than 1100 Polygons. The geometry type in that table is multipolygon. There are only some real Multipolygons inside and I need only polygons. How can I find the multiparts? How can I split the multiparts? Also are there some polygons without geometry. What is the way to identify them? I want to do that work in the database but could do it also in QGIS.

Ian Turton
  • 81,417
  • 6
  • 84
  • 185
Torsten
  • 396
  • 1
  • 8

1 Answers1

5

In SpatiaLite, you can use the function ElementaryGeometries such as the following code :

SELECT ElementaryGeometries('multipoly', 'geom', 'singlepoly','gid','fid') as geom
FROM multipoly

This function create a new table singlepoly where each multipolygon of the table multipoly is converted to a simple polygon. For example, I had one feature. For example, I had a multi-polygon with 4 features. On output, I get a table with 4 rows.

In QGIS, you can use the following tool : Vector > Geometry tools > Multipart to Singleparts.

Vincent Bré
  • 4,090
  • 7
  • 23
  • 1
    SpatiaLite does have a function for that and it is called ElementaryGeometries https://www.gaia-gis.it/stored-procs-win-test/spatialite-sql-latest.html. – user30184 Feb 14 '20 at 10:30
  • Thank you, you're right! I edited my answer. – Vincent Bré Feb 14 '20 at 10:53
  • 1
    Thanks a lot. That helps. There are some additional questions: How could I identify and select the rows with multiparts? How coul I copy/save the polygons from the table with geom MULTIPOLYGON into a table with geom POLYGON? – Torsten Feb 14 '20 at 13:04
  • You-re welcome! You can accept my answer if it helped you! I advise you to open a new post to ask your question. – Vincent Bré Feb 14 '20 at 13:23