I have an area (polygon layer AoI in red) for which I want to evaluate the total overlap of polygons within a different layer, with the catch that within that layer, polygons are overlapping each other (multiple times) and I want to count that area as well.
polygons of two layers, with several overlapping polygons within in one layer
I've established that the QGIS overlap analysis tool doesn't calculate multiple overlaps within the same layer.
There are similar questions, mostly ten years old and mostly revolving around finding and extracting that overlap (which would also help in some cases, but as soon as more than two features overlap it will get tricky again):
- Calculating Feature Overlap Area within Single Shapefile
- How to calculate the area of overlapping buffers within a single layer
- Extracting Overlapping Parts of Single Polygon Layer using QGIS?
- how to extract overlap from non-dissolved buffer zones in qgis 1.7.4
These questions are either unanswered, unsolved or suggest non-QGIS tools. I am wondering whether 10 years later, maybe we can find a QGIS solution with QGIS board tools?
One promising answer led me to an approach with PostGIS, which sounds like it would have more powerful tools to do what I want, but I'm not that familiar with how I would implement a solution for my problem with that in QGIS.
The most promising answer/approach for me was this one, suggesting a solution for ArcGIS, where I modified step 1 to 4 here for QGIS, but I get stuck at the last step:
- Run the Union tool on the polygon feature class.
- Add the field
x
(Double) with field calculator:x(@geometry)
- Add the field
y
(Double) with field calculator:y(@geometry)
- Add the field
count
(integer) as1
- Run the dissolve tool on x and y fields and also allow for the SUM of the count in the statistics field. <<< how do I do that?!
If I'd solve step 5, I could use count
to multiply the $area
and from there on I would find a solution to aggregate this per area of interest. It still would be a mess and anything but elegant, but I'd see a way; but I don't see how I achieve a "Dissolve with sum" in QGIS.
-
If you run an intersect overlay, overlapping polygons should be preserved but "cut" at the AOI boundary and given the AOI attribute. So if all you want is the total area of all the polygons in that AOI just recalculate the area field. But since that's rather simple perhaps that isn't what you are looking for. To get more info on the overlaps you could instead clip your overlapping polygons layer with the AOI, and then run the SAGA Polygon self intersection tool.John– John2025年04月09日 22:38:55 +00:00Commented Apr 9 at 22:38
1 Answer 1
- Clip
- Union the output with itself as input, no overlay layer. This will create duplicate geometries where there are overlaps.
- Aggregate and group by WKT geometry
geom_to_wkt($geometry, 0)
and count, sum your fields.
-
1Great, that is even more elegant and unambiguous than the workaround with creating the X, Y fields (which might falsely dissolve if geometries that are not identical share the same corner point). This is also flexible enough to do anything (sum area, count overlap, identify / extract areas with certain overlap properties). Really glad that to now know about this tool! I actually had it open but wasn't sure on how to group on the X and Y coordinate fields. Just out of curiosity: How would that go? Group expression:
"X" || "Y"
?Honeybear– Honeybear2025年04月10日 05:17:50 +00:00Commented Apr 10 at 5:17 -
1Nice!
x($geometry) || y($geometry)
seems to be workingBera– Bera2025年04月10日 05:28:12 +00:00Commented Apr 10 at 5:28
Explore related questions
See similar questions with these tags.