# Summing area of polygons within vector layer within zone using QGIS

I have one vector layer with multiple polygons (purple). I also have a number of other vector layers which are catchment zones (I also have a layer where these catchments are merged).

Is there any way I can sum/calculate the areas of the purple polygons within each of the individual catchment zones?

I need this to work out a percentage of the area taken up by the purple polygons within each catchment.

In QGIS I can suggest using a "Virtual Layer" through `Layer > Add Layer > Add/Edit Virtual Layer...`.

Let's assume there are ten features in 'multiple_polygons' (yellow), and three in 'catchment_zones' (grey) accordingly, see image below.

With the following Query, it is possible to achieve the result

``````SELECT
c.id,
c.Name,
c.geometry,
ROUND(st_area(c.geometry), 2) AS "catch_area(m*m)",
ROUND(SUM(st_area(m.geometry)), 2) AS "mult_area(m*m)",
COUNT(m.geometry) AS "num_mult",
ROUND(SUM(st_area(m.geometry))/st_area(c.geometry)*100, 2) AS "area_%"
FROM
"catchment_zones" AS c
JOIN
"multiple_polygons" AS m
ON st_intersects(c.geometry, m.geometry)
GROUP BY
c.id
``````

The output Virtual Layer will maintain the original geometry and some initial attributes including several new, namely `"catch_area(mxm)"` (in square meters), `"mult_area(mxm)"` (in square meters), `"num_mult"` and `"area_%"`.

1. Intersect
2. Dissolve based on catchment ID
3. Create new field and calculate area

Create a new attribute with field calculator. If your layers have the names `polygons1` (the catchment zones) and `poly2` (your small, purple polygons), then on `polygons1` use this expression: `array_sum(overlay_contains ('poly2', \$area))`.

Here, the organge layer is labeled with the expression from above, calculating the sum of the areas of all blue polygons contained inside each of the orange polygons: