When combining two layers the "Union" tool works fine, and I have used Union several times: A + B => AB, then AB + C => ABC, then ABC + D => ABCD, and then ABCD + E => ABCDE and so on ...

I have found under the Vector menu > Data-managing-tool (I guess because my menu is in Swedish) and then > join-vector-layers. But that tool just puts everything on top of each other. I want the layers to properly Union.

Whats the most easy way to Union five vector layers?

  • 2
    [1] Merge all layers with the "Merge" tool [2] Give a new unique "id" [3] Apply the Polygon Self-intersection tool. P.S. Step [2] is optional
    – Taras
    Jun 15, 2021 at 11:07
  • 1
    It works but it isn't the same result as union (many times). You lose the attributes. Jun 15, 2021 at 12:59
  • You might look at the graphical modeler. Without an iterator and feedback loop it's not as simple as ArcGIS model builder but for five inputs it is relatively easy to set up and run, and you can save it for repeated/future use.
    – John
    Jun 16, 2021 at 20:34
  • If I lose the attributes its no good Jun 17, 2021 at 13:31

1 Answer 1


Building on the comment provided by @Taras, here is a workflow to try assuming that all of your inputs are polygon layers:

  1. Merge all of the inputs Merge tool.

  2. Add/calculate a unique id field - ex. using the variable @row_number in the field calculator.

  3. Use the GRASS v.clean tool (available in the QGIS Processing Toolbox - ensure that you are using the "QGIS with GRASS" executable) to "flatten" all of the overlapping polygons - a new polygon will be created for each overlap.

  4. If you would like to then aggregate/summarize the output, you can use the QGIS Aggregate tool, with geom_to_wkb($geometry) as the group by expression and then summarize/aggregate the other fields as you wish.

To avoid problems/errors, you should ensure that all of your inputs are valid (run the Fix geometry tool), single part (Multipart to single parts tool) and have a geometry index (Create spatial index tool).

If your inputs are complex or have many vertices, you can use the Subdivide tool to make them easier to process.

Note: You can also try to run the QGIS Union tool on the merged inputs without providing an overlay layer. This should essentially do the same as GRASS v.clean with the default options. I have found GRASS v.clean to be more robust.


Your Answer

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

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