I want to create a new MultiPolygon shapefile, I tried this code

Mp_Layer = QgsVectorLayer('MultiPolygon?crs=EPSG:26191', 'layer', 'memory')

But when I check the wkt_geom if the created shapefile its gives a polygon type.

It’s possible to create a Multipolygon directly by PyQGIS?

  • 3
    The layer is type polygon but the geometry stored in it can be multipolygon, which indicates the geometry has multiple parts, either exterior rings or interior rings (holes). Although qgis.org/pyqgis/3.4/core/QgsVectorLayer.html indicates that the memory provider can have type “point”, “linestring”, “polygon”, “multipoint”,”multilinestring”,”multipolygon” I suspect, without digging too deep into the source code, that linestring = multilinestring and polygon = multipolygon for the constructor (point != multipoint - special case) in keeping with OGC standards for geometry storage. Nov 12, 2019 at 22:57
  • Thanks for your answer, i want to know if i can change the geometry Type from Polygon to MultiPolygon or create a new shapefile file as MultiPolygon. That because i have already made many function based on Wkt of MultiPolygon type. Nov 13, 2019 at 10:52
  • 1
    I had similar issues with shapefiles being created with the wrong wkt. gis.stackexchange.com/a/259762/56050 I was using the QgsVectorFileWriter, and I'm not sure if it's related, but there may be some info there that may be helpful.
    – TJR
    Nov 19, 2019 at 16:06


Your Answer

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

Browse other questions tagged or ask your own question.