Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

The image below shows my shp-file. Every polygon has the same transparent color. So a darker blue means, that several polygons are stacked! How do I cut every polygon with each other so no polygons are stacked anymore?

enter image description here

share|improve this question
Are all of these polygons contained in a single vector layer? – Jordan Arseno Apr 28 '13 at 23:34
Can you share a subset of your shape file so we can experiment with it? It would also help if you'll answer @JordanArseno's question. – R.K. May 2 '13 at 8:08
If you have the Grass plugin you could clean your layer to "flatten" it but if you need the attributes (as you probably will) a spatial join will likely only get you part way there and the rest would need to be done manually. I think Sextant also provides access to the Grass clean. – johns Jul 25 '13 at 17:18

If I understand correctly, the single shapefile contains overlapping-features (polygons). The brute force way if there's not many polygons...

(1) Save each polygon out as a separate shapefile using your classification as in this question.

(2) UNION the shapefiles.

share|improve this answer
It used to be possible just to union a layer with itself. Has that changed? – whuber May 24 '13 at 19:20
@whuber not sure, as I don't normally have shapefiles in this manner. If so, then that would be a lot easier for the OP. – Zach May 24 '13 at 20:47
I tried the union geoprocessing tool in QGIS on a sample datset with itself and it created a much larger number of polygons with a geometry error warning in QGIS 1.8.0. If QGIS had a batch union to go with the split layer tool that would be useful in some situations for a modest number of polygons or classes of polygons in a dataset. We do this in ArcGIS occasionally. – johns Jul 25 '13 at 17:52
You can union within one feature class, no problems there. After union you would have to get rid of duplicates. – Tomek Jan 20 '14 at 12:29

If you have arcgis (info license) then use the 'ERASE' tool. This will cut the donuts out. Or start editing and use the merge option under the editor toolbar and just merge into each other.

share|improve this answer

Simply erasing polygons here to generate holes will not work. You will always need to erase based on overlap (for example, erase the small polygon that is on top of the bigger polygon and not the other way around). My suggested workflow would be as follows:

  1. Grab all the geometries and save them in a list.
  2. Order the list by area descending (first geometry has biggest area)
  3. Put them in some sort of index
  4. For each polygon geometry (x), do the following:
    1. Grab all overlapping polygons using the index (y)
    2. Calculate the area overlap between x and each y
    3. For each actual overlap:
    4. Find the largest overlap by area
    5. If the overlap is partial, erase that from x
    6. Make sure the rest of the potential overlaps are still overlaps of the new x

Note that this solution is not necessarily going to work as there are some more issues based in the ordering you do things, as well as the overlap (will some polygons completely disappear?).

You can solve this in arcpy, ogr and probably shapely. I assume QGIS has similar functionality, but I cannot speak to it.

Other thoughts: 1. Don't forget a geometry object usually has a .area attribute 2. If using Python, sorting a list by the .area attribute becomes trivial 3. Geometries have intersect methods, as well as erase methods 4. The returned geometries from intersect methods can help you identify percentage of area you will potentially erase

Hope this helps a little bit.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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