3

I want to export a layer with holed geometries in it. But when I save my features to shapefile in QGIS 3 it creates a file with MultiPolygon as geometry type. The fact is that a holed polygon isn't a multi-surfacic polygon and I want to export it as Polygon only.

I tried to modify manually the WKT with geom_from_wkt() with following formula :

geom_from_wkt( replace( replace( geom_to_wkt( $geometry ), 'MultiPolygon (', 'Polygon '), ')))', '))' ) )

With Geometry by expression and the temporary layer created by this algorithm is correct (with Polygon type) but when I save it to shapefile it puts MultiPolygon back again.

1 Answer 1

4

This is unfortunately always going to happen. Since shapefiles don't distinguish between multi and single geometry types QGIS (and other software) has to "promote" the geometries to the multi form just in case there are some multis hiding in the file.

MultiPolygons with just one polygon in them are completely valid and can be used everywhere a polygon can be so don't worry about it too much. If you absolutely must have polygons then you could use ogr2ogr with the -nlt POLYGON option to force all the geometries to be polygons (whether they are or not).

1
  • Class: QgsGeometry -> 'asPolygon()' method will have issues with MultiPolygons.
    – cm1
    Commented Jun 10, 2022 at 19:57

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.