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?
-
2Are all of these polygons contained in a single vector layer?– Jordan ArsenaultApr 28, 2013 at 23:34
-
2Can 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, 2013 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.– JohnJul 25, 2013 at 17:18
3 Answers
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.
-
It used to be possible just to union a layer with itself. Has that changed?– whuberMay 24, 2013 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.– ZachMay 24, 2013 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.– JohnJul 25, 2013 at 17:52
-
You can union within one feature class, no problems there. After union you would have to get rid of duplicates.– TomekJan 20, 2014 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.
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:
- Grab all the geometries and save them in a list.
- Order the list by area descending (first geometry has biggest area)
- Put them in some sort of index
- For each polygon geometry (x), do the following:
- Grab all overlapping polygons using the index (y)
- Calculate the area overlap between x and each y
- For each actual overlap:
- Find the largest overlap by area
- If the overlap is partial, erase that from x
- 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.