1

i've seen this tutorial that explains how to merge two polygon features in QGIS.

Doing it works, but when I stop editing the layer, I got a message

Could not commit changes to layer drawingPolygons

Errors: ERROR: 1 feature(s) not added - geometry type is not compatible with the current layer.

My layer is a geoJson file. A feature looks like

{
  "type": "Feature",
  "properties": {
    "id": 632,
    "title": "",
    "media_url": "JETTE32.png",
    "media_id": 629,
    "type": "raster"
  },
  "geometry": {
    "type": "Polygon",
    "coordinates": [
      [
        [
          4.308976117998887,
          50.88773442630111
        ],
        [
          4.357000053136904,
          50.88773442630111
        ],
        [
          4.357000053136904,
          50.86630843201042
        ],
        [
          4.308976117998887,
          50.86630843201042
        ],
        [
          4.308976117998887,
          50.88773442630111
        ]
      ]
    ]
  }
}

We can see that the coordinates property is an array.

So I was thinking it would support multiple polygons, but seems it is not.

I also tested by setting "type": "MultiPolygon" instead of "type": "Polygon" by editing my geojson file with a text editor, but then it doesn't load anymore in QGIS.

Can anyone help ?

1

1 Answer 1

0

Multipolygon is an array of polygon coordinates. So you'll need to wrap the coordinates in another array. Try this:

{
  "type": "Feature",
  "properties": {
    "id": 632,
    "title": "",
    "media_url": "JETTE32.png",
    "media_id": 629,
    "type": "raster"
  },
  "geometry": {
    "type": "MultiPolygon",
    "coordinates": [[
      [
        [
          4.308976117998887,
          50.88773442630111
        ],
        [
          4.357000053136904,
          50.88773442630111
        ],
        [
          4.357000053136904,
          50.86630843201042
        ],
        [
          4.308976117998887,
          50.86630843201042
        ],
        [
          4.308976117998887,
          50.88773442630111
        ]
      ]
    ]]
  }
}
1

Your Answer

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

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