I've been reading through question and answers on the Aggregates Function, but have been unable to obtain a clear understanding and solution to my problem. I have a polygon grid ("Grid 4km") and I have another vector polygon layer ("S1 Grid Intersection Strata"). I want to calculate the area of the polygon layers that are within a grid cell. I intersected the vector polygon layer with the grid so that you can select on polygons within the grid.
The steps I have taken so far:
- I calculated the $area in a field called Area in "S1 Grid Intersection Strata".
I worked in the field calculator for "Grid 4km" to create a new field called "S1 Area" using the following:
aggregate('S1 Grid Intersection Strata', 'sum', "area", filter:=intersects($geometry, geometry(@parent)))
This seems to work, but when I select on individual examples and calculate by hand the sum of the area is not what is showing up in the new "S1 Area" field. The image below shows the polygons selected within the grid with the area values. The sum of the areas in the "S1 Grid Intersection Strata" do not add up to the value in the "Grid 4km" "S1 Area" field.
I am hoping that someone might be able to provide a good explanation of what the @geometry component in the formula above is doing and how I can fix this to sum up the area of the intersecting polygons in the grid.