# Calculating polygon area within polygons in QGIS?

I am new to QGIS - I want to estimate the area of the reef under a polygon grid.

My shapefiles are already in meters, however I am having a hard time calculating the area under the grid layer. Attached are the photos.

I want to calculate the total area of the bold black polygons (reefs) under each grid square (image 2). How much reef is inside each square, for example, grid1: 25 sq.km, grid 1 sq.km, etc. Each reef polygon has its corresponding area in the layer attribute table.

ADDITIONAL PHOTO: RED IS THE REEF

THE ATTRIBUTES OF THE REEF LAYER

• The reefs are all the bold black smudges? And you want the area they cover? Or do you need the area of all the grid-boxes overlaying reefs combined? – Erik Oct 9 '18 at 8:21
• Thanks Erik. The reefs are the bold black points, And I want to estimate the area covered under each grid. – Gie Oct 9 '18 at 8:23
• As in grid-box 1 covers 1acre of reef, grid-box 2 covers 5 acres, etc? – Erik Oct 9 '18 at 8:25
• That's right, how much reefs are within the extent of each grid. ex: grid1: 25, 000 m2, grid: 3000 m2...and so on (in square meters or sq. km) – Gie Oct 9 '18 at 8:27
• Are your reefs in point feature format? Are they graduated based on areal extent? If not, how is the data regarding the areal coverage of each 'reef point' incorporated into your project? – Maggie Oct 9 '18 at 8:36

Note this solution relies on QGIS calculating the polygon area, rather than utilising the area data contained within the attribute table already. If this would cause accuracy issues, you will require an alternative solution!

1) Processing toolbox > vector overlay > intersection

input layer = coral reef vector

intersection layer = grid square layer

2) vector geometry > dissolve

input layer = intersected layer from step 1.

Unique ID fields = the 'ID' field from your grid vector layer (which should now be one of the fields in your new 'intersection' output layer. This step faciliates an association between all polygons that fall within a given grid square ID.

3) Open the attribute table of your new 'dissolved' output layer, created by step 2.

Open 'Field calculator' > in the 'expression' builder, enter '\$area' (without the inverted commas)

Tick box 'Create a new field'; enter a name for your new field column in 'output field name' ('Reef_area'?). Make sure to uncheck 'Only update selected features'. Execute.

Hope this resolves your problem. Good luck!

In QGIS 3.0.2 the tool I have used to solve this can be found here:

Toolbox > vector analysis > count points in polygon

Your 'polygon' should be the grid squares. Note there is a 'selected features only' tick box, if you wish to calculate for only specific polygons at a time.