8

I need a union function for a lot of polygon layers (protected areas of all kind, nature, water etc.) comparable to the union function in ArcGIS. I have only the desktop version from ArcGIS and so it will only work on two layers.

I am looking for the same function in QGIS or another opensource GIS (openjump, gvsig....). I have tested MMQGIS and other functions in QGIS but I need union I think. I have merged layers in QGIS then worked my way with different spatial intersections in ArcGIS but thats all very complicated. I did union theme by theme in ArcGIS but in the end, I will have hundreds of themes so that is just impossible and union is just what I need.

The result should have all the attribute information of overlaying layers and the polygons should be split. An overlaying layer counts as an additional result and would be nice but not absolutely necessary as first impressions of how many different kinds of protected areas overlay. But in the end, it is most important that I do not lose any information for every little split polygon because I have to justify why or why not this exact polygon is convenient or not.

5 Answers 5

6

You can do this in QGIS, there is a Merge shapefiles to one function. This, compared to Union which only combines 2 layers, combines multiple shapefiles (selected either individually or by a directory) into one, contains additional results if there are any overlaps and no attribute fields are lost in the final layer. First install the fTools plugin:

Plugins

Once installed, you should see a set of new functions in the Vector menu from the toolbar:

Merge

5
  • Hello Joseph, that works only for two layers thats the problem :-(
    – Richard
    Commented Oct 2, 2014 at 10:24
  • Thanks @Richard, I've edited my post which hopefully will be more helpful.
    – Joseph
    Commented Oct 2, 2014 at 12:16
  • 1
    The merge shapes in to one function works for more than 2 shapes. I have been able to merge more than 20 at once. Commented Oct 2, 2014 at 13:05
  • Thanks @GerardoJimenez, that was what I meant in my post and I've edited it to make it more clear :)
    – Joseph
    Commented Oct 2, 2014 at 13:12
  • Hello Joseph, thanks again, I have tried shapes merge I know that this is no problem and you have different tools to do it with as many polygons as you like. But merge dont do the job because it dont split the overlying polygons. I think I will have no chance, learning scipting or doing it manually or mege with additional spatial intersechtions.
    – Richard
    Commented Oct 6, 2014 at 5:49
4

You can use ogr2ogr tool in batch like this:

first:

ogr2ogr merge.shp file1.shp 

to create a shapefile merge containing the data of file1

then:

for %f in (*.shp) do (
ogr2ogr -update -append merge.shp %f  -f “esri shapefile” -nln merge 
)

to loop over all shapefile in the current directory and merge all to merge.shp

A second option is to use this script: http://hub.qgis.org/attachments/5521/shapemerger.py

1
4

try OpenJUMP. you can combine layers into new ones keeping the attributes, extending the schema if necessary

combine layers is avail in the layer tree context menu

result

3

If you are comfortable using Union in ArcGIS for Desktop, then to get around the Basic level licensing restriction to union multiple feature classes together, I usually write a list of the feature classes that I want to Union together down on a piece of paper, and then use a "Tennis Tournament" concept to perform a minimum number of pairwise Unions to get my final result (in this case a Union of 7 feature classes):

Union FC1 and FC2 => U1
                       > Union U1 and U2 => U4       
Union FC3 and FC4 => U2
                                               > Union U4 and U5 => U6 (the Result!)
Union FC5 and FC6 => U3
                       > Union U3 and FC7 => U5
FC7

It will be a much longer list for hundreds of feature classes but it should be possible to code this in Python using something like Algorithm for generating a bracket model list in Python from StackOverflow.

0
2

Update to Joseph's answer: in QGIS 3.x the "fTools" Plugin doesn't exist anymore. However there is a standard function available (see screenshot) that does just the same.

mergeVectorLayers

1
  • There is a new QGis3 plugin named "Multi Union" !
    – MLourdes
    Commented Nov 15, 2023 at 18:21

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.