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.
1 Answer
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
.
-
1SpatiaLite does have a function for that and it is called ElementaryGeometries gaia-gis.it/stored-procs-win-test/spatialite-sql-latest.html. Feb 14, 2020 at 10:30
-
-
1Thanks 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?– TorstenFeb 14, 2020 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. Feb 14, 2020 at 13:23