3

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.

  • Saving a Polygon layer to GeoJSON from QGIS should not convert the type to MultiPolygon. Could you please update your question to describe how you create the layer and convert it to GeoJSON? – Jake Mar 28 at 10:36
  • HI Jake thank you for your comment , but I am noticing that this is happening in QGIS when there is no option to set it to MultiPoligon , just Polygon on drop down menus. I am having to edit the files in geonJson text format now . I created the shape file specifying polygon in Newshape and saved with only Polyon in export to Geojson. Yet the files still do not only have Polygon they have MultiPolygon in them . I am also noticing some have Feature Collection which was not put there either with only one feature in them – Martin Mar 30 at 13:04
  • It inserts {"type":"FeatureCollection","features":[{"type":"Feature","id":"751672da-d59d-40d2-9144-302d4df889e9","geometry": – Martin Mar 30 at 13:45
  • Could you clarify your question a bit: What do you mean by "rastering maps (...) to provide GeoJSON files"? Why do you need to use GeoJSON if these files are only intermediate steps? Why do you use MMQGIS for merging the GeoJSON files, rather than "Vector / Data Management Tools / Merge Vector Layers" tool? Could you post a screenshot of the algorithm configuration menu? – Jake Jun 2 at 11:51
1

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.

| improve this answer | |
  • Hi Jake thanks for this clarification on the MultiPolygon or Polygon Question , however it has not been explained how some Geojson had FeatureCollection in them as they was all created with single features in them . They have all been edited out now . I would imagine this FeatureCollection tag was used for multiple feature ? – Martin Apr 5 at 9:16
  • @Martin: When exporting to GeoJSON, QGIS does not check whether a layer contains zero, one, or more features. Instead, it will always create a FeatureCollection which then contains all features of the layer. This makes sense because a FeatureCollection maps most closely to QGIS' concept of layers (which are also collections of features and can contain zero, one, or more features). – Jake Apr 5 at 15:35
  • Hi Jake. I just cant merge them in 3.10.6 or 3.12.1. As I said above it reports an error whilst merging and overtime has changed my files back to multipolygon and polygon. 3.12 states the outputs are not supported.on 3.10.6 it returns and error Polygon != MultiPolygon. I understand you gave a source file it seems to be converting input files to string why is it reporting back "files are not supported as an outputs for this algorith" and where is this message created in the source please as I stillcant see why it wouldreturn these strange messages? – Martin May 29 at 10:32
  • I forgot to say the last error is in 3.12.1 – Martin May 29 at 14:01

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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