3

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):

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:

  1. Run the Union tool on the polygon feature class.
  2. Add the field x (Double) with field calculator: x(@geometry)
  3. Add the field y (Double) with field calculator: y(@geometry)
  4. Add the field count (integer) as 1
  5. 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.

asked Apr 9 at 17:40
1
  • 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. Commented Apr 9 at 22:38

1 Answer 1

7
  1. Clip
  2. Union the output with itself as input, no overlay layer. This will create duplicate geometries where there are overlaps.
  3. Aggregate and group by WKT geometry geom_to_wkt($geometry, 0) and count, sum your fields.

enter image description here

answered Apr 9 at 18:32
2
  • 1
    Great, 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"? Commented Apr 10 at 5:17
  • 1
    Nice! x($geometry) || y($geometry) seems to be working Commented Apr 10 at 5:28

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.