5

I am working in QGIS 3.10.4 trying to capture zonal stats for a polygon within a polygon. For example (picture below), two red lines make up a rectangular polygon that hold its blue circular polygons. Each blue polygon within its respective rectangle has an area calculation. I want to find the average area of the blue circular polygons in respect to its row. I initially tried zonal stats, but soon realized that zonal stats only work with a raster.

Any thoughts on how to do this?

enter image description here

4
  • 1
    The 'Join attributes by location (summary)' tool in the processing toolbox will work. I would recommend using a projected CRS for both layers. You will need a field in your blue polygon layer containing the area of each feature (you can create this in the field calculator with $area expression). Then run the tool with rectangles as input, blue polygons as join layer, select your area field under 'Fields to summarise' and mean under 'Summaries to calculate'.
    – Ben W
    Commented Aug 22, 2020 at 1:34
  • This is the tool I am looking for. I have inputted what you suggested, it runs, but the output mean column is all NULL.
    – Binx
    Commented Aug 22, 2020 at 5:05
  • For the "geometric predicate", I am using within and touches.
    – Binx
    Commented Aug 22, 2020 at 5:12
  • 1
    Switched "within" to "contains" and that worked. Could you please post your solution.
    – Binx
    Commented Aug 22, 2020 at 5:15

1 Answer 1

5

You can use the 'Join attributes by location (summary)' tool in the processing toolbox. I would recommend using a projected CRS for both layers. You will need a field in your blue polygon layer containing the area of each feature ( if you don't already have this you can create it in the field calculator with $area expression). Then run the tool with your rectangle polygon layer as input and blue circular polygons as the join layer. Use 'contains' as the geometric predicate. Then select your area field under 'Fields to summarise' and 'mean' under 'Summaries to calculate'. You will get an output of your rectangle polygon layer with a new field containing the average area of the smaller polygons contained in each feature.

enter image description here

Your Answer

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

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