2

I'm trying to merge some polygons together and I know that they all have valid geometries, but for some reason I'm still getting the error message saying:

Merge failed: An error occurred during the merge operation

I'm not given any context as to what caused it to fail, so I don't know how to fix the issue. The vast majority of the time this has happened to me is when something has invalid geometry, but I've ruled that out. I've also run into problems with multipart polygons not working well when there are little slivers cut off from the main body and bordering several other polygons. However, that's not the case here either. What else could be causing this message?

3
  • You are using "Merge Vector Layers" geoprocessing tool? That tool is buggy. Do you need any attributes or just the geometries?
    – BERA
    Oct 27, 2021 at 11:14
  • Do the SAGA and (if you have it installed) the Whitebox Merge layers tools also fail? If you are saving to a temporary (hence gpkg) does the merge work if you save to a shapefile or some other type; or if saving to a file and try the temporary one does that work? If you create temporary copies of the inputs (easily done by using the Check Validity tool on each) and delete their fields can you merge those? I can imagine that some data types may have fields that aren't acceptable in the output.
    – John
    Oct 27, 2021 at 13:49
  • In helping a co-worker today I was reminded of another reason the merge tool fails. In this case the same field was integer in one layer and real in another.
    – John
    Dec 23, 2021 at 17:28

1 Answer 1

1

As an alternative to the merge tool, you can simply buffer the geometries with a distance of 0 to get the same result. Use one of these two options:

  1. Use Menu Vector / Geoprocessing Tools / Buffer:

    • set a buffer distance of 0
    • check the box next to Dissolve results
    • click only selected features if you want to merge only the selected geometries.
  2. Use Geometry by expression with this expression: buffer (collect ($geometry),0), see screenshot, where Geometry generator is used for visualization purpose to generate the merged version (blue point pattern fill with red outline) from the initial polygons (orange solid fill with black borders):

enter image description here

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.