[GIS] GeoJSON single feature Polygons changed to MultiPolygon by QGIS and how to convert

convertpolygonqgis

I have been rastering maps in QGIS 3.10.2 to provide GeoJSON files and layers in QGIS even though these are created in QGIS as a new shape with the 'Polygon' choice selected and then exported to GeoJSON the files and layer end up as MultiPolygon with a single feature in each. I have around 620 of these single feature MultiPolygon layers in QGIS and cannot understand how they have been created with only one feature in them? MMQGIS refuses to merge these giving an error Merged layers must all be same type of geometry (MultiPolygon != polygon).

I presume these must have Polygon geometry to allow them to be merged in MMQGIS. Is there a simple way to convert these in bulk to the correct geometry for MMQGIS to merge them? I understand there is software that can do this but would like a step by step solution if possible using existing software.

Hi thanks for the answers on how to create these GeoJSON that was not what I required since changing these manually to polygon they have returned to there original state of both Polygon and Multi Polygon. when QGIS has recognised them after the change to Polygon and gave some other unknown reason for failing to merge.

I should add 3.12 lists the item with there CRS /SRS so its easy to pin down a geometry that is wrong nice addition.

3.12 is slightly different with its vector merge it gives a response "files are not supported as an outputs for this algorithm" I don't know how to get around this other than someone said to use GRASS

This is now becoming urgent as QGIS 3.12.1 constantly tries to index every layer for some reason driving us mad.

Best Answer

Shapefiles don't differentiate between Polygon and MultiPolygon - all Polygon shapefiles can contain MultiPolygons. When you convert a Polygon shapefile to a GeoJSON file, a MultiPolygon is used for each feature to ensure that the feature geometry can be correctly saved.

To generate a Polygon GeoJSON file (rather than a MultiPolygon GeoJSON file) you can use the "Multipart to Singleparts" tool from the "Vector"/"Geometry" menu, choosing "Save to file" option and selecting GeoJSON as the output type.

Related Question