7

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.

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

  • Hello Joseph, that works only for two layers thats the problem :-( – Richard Oct 2 '14 at 10:24
  • Thanks @Richard, I've edited my post which hopefully will be more helpful. – Joseph Oct 2 '14 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. – Gerardo Jimenez Oct 2 '14 at 13:05
  • Thanks @GerardoJimenez, that was what I meant in my post and I've edited it to make it more clear :) – Joseph Oct 2 '14 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 Oct 6 '14 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

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

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

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.