# Area calculation in QGIS

## Introduction

Amidst the Coronavirus twists and turns reported in the news of late 2020, the journey of A68 Iceberg became a firm topic of conversation among the polar community and wider public.&#x20;

Since calving from Antarctica's [Larsen C ice shelf](https://en.wikipedia.org/wiki/Larsen_Ice_Shelf#Larsen_C) in July 2017, the berg had been drifting slowly northwards. Once it was within striking distance of South Georgia, the speculation began. Would it cause environmental damage to the remote island's biodiversity? Would it ground off the coast and hang around for a few more years? Would it drift by and break up?&#x20;

And, how big is it anyway?

This tutorial will explain how to perform an area calculation in QGIS, using a digitised polygon of A68 iceberg as an example.&#x20;

## Learning outcomes

* Awareness of coordinate reference system considerations when calculating areas
* Geometry calculations of vector polygons in QGIS using Field Calculator

## Tools required

QGIS Desktop v3.x. We recommend using the current Long Term Release version.&#x20;

## Datasets

We will be using a dataset of vector polygons defining the size, shape and position of the iceberg through time (`iceberg_a68.gpkg`). This has been produced by Laura Gerrish, Mapping Team, BAS. You can download this below:

{% file src="/files/-MjV-dBPQ31Z7TfWdx-D" %}
iceberg\_a68.gpkg
{% endfile %}

It is also recommended to download the latest coastline of South Georgia <https://www.sggis.gov.gs/> to provide context.&#x20;

The coordinate reference system of both the iceberg polygons and the ADD coastline is [WGS84 / South Georgia Lambert](https://spatialreference.org/ref/epsg/wgs-84-south-georgia-lambert/) (EPSG:3762).

## The exercise

### Step 1: Load the datasets into a new QGIS project

1. Open QGIS
2. Drag and drop the two datasets into the project. You will first have to unzip both `iceberg_a68.zip` and the coastline (download if you obtained it).&#x20;
3. Zoom to the extent of the layer `iceberg_a68`

![](/files/-MjV05nID4NGP3dNOZDe)

{% hint style="info" %}
You will notice the coordinate reference system (CRS) of the QGIS project has been set to [WGS84 / South Georgia Lambert](https://spatialreference.org/ref/epsg/wgs-84-south-georgia-lambert/) (EPSG:3762). This is because QGIS will set it's project CRS to match that of the first dataset that is loaded into a new project.&#x20;
{% endhint %}

### Step 2: Query the `iceberg_a68` layer

Now is a good time to have a closer look at the iceberg polygon data.

1. Select the **Identify Features** tool.
2. Click on any of the iceberg polygons to reveal the attribute information associated with each polygon.&#x20;
3. Right click on the `iceberg_a68` layer in the layer menu and select **Open Attribute Table** to view the date of each polygon and imagery source for each polygon in table form.&#x20;

{% embed url="<https://web.microsoftstream.com/video/43800071-275f-4318-a09d-fb3cb2b4ecd4>" %}

### Step 3: Calculate the areas of the polygons

{% hint style="warning" %}
As mentioned, the coordinate reference system (CRS) of the `iceberg_a68` layer is WGS84 / South Georgia Lambert. This projection is not an equal area projection, therefore if we calculate the area of the polygons using this CRS, the numbers will not be accurate.&#x20;

We can re-project the data to a CRS that will preserve areas. As the iceberg is relatively, this method should provide us with accurate results

However, we can also calculate areas on the ellipsoid, which involved more complicated mathematics, but we can also be sure it will provide accurate results, no matter how large an area we are calculated over.&#x20;
{% endhint %}

#### Set QGIS to calculate areas on the ellipsoid

In the **Project** menu, select **Properties**. In the dialogue window that appears, choose the **General** tab. Choose the `WGS84` ellipsoid in the Ellipsoid drop-down menu under **Measurements.**&#x20;

{% hint style="info" %}
Notice the units are in square metres for area. We can change this to suit the purpose.&#x20;
{% endhint %}

![](/files/-MjV0FWR8dz1dhCkShEb)

#### Calculate the area of the polygons

To calculate the area of each individual polygon, we will first open the **Attribute Table**, and use the **Field Calculator** to extract the area geometry of each feature to a new field in the table.&#x20;

{% embed url="<https://web.microsoftstream.com/video/09190223-c05f-499e-94ea-03d2745cada1>" %}

### Bonus step: Calculate the areas of the iceberg polygons using an equal area projection

Step 3 above demonstrates a good way to calculate areas in QGIS. This is a good method for making sure we get accurate area calculations.&#x20;

However, it is just as valid to calculate areas using a planimetric calculation, if the map projection we are using is suitable, ie. it is an equal area projection.

As stated above, the CRS of the `iceberg_a68` layer is not an equal area projection. As such there are a few steps we need to take before we can re-do the area calculation using the Field Calculator.&#x20;

1. &#x20;Re-project the data to an equal area projection
2. Change the QGIS project properties to calculate using the datasets CRS, rather than the ellipsoid &#x20;
3. Re-run the field calculator process

#### 1. Re-project the `iceberg_a68` to an equal area projection

1. Right click on the layer in the layer menu and choose **Export** > **Save Features As.**
2. Choose output format at Geopackage
3. Change the CRS to EPSG:102020 South Pole Lambert Azimuthal Equal Area.
4. Save the dataset.

The dataset will appear automatically in your QGIS project. You can confirm the projection of the dataset by right clicking on the layer and selecting **Properties**.

#### 2. Change the QGIS project properties to calculate using the datasets CRS

In the **Project** menu, select **Properties**. In the dialogue window that appears, choose the **General** tab. Choose the `None / Panimetric` option in the Ellipsoid drop-down menu under **Measurements.**&#x20;

This will ensure QGIS uses the coordinate reference system of the dataset when it performs geometry calculations in Field Calculator.

![](/files/-MjV0NZ12HUd0X-Vqsyi)

#### 3. Repeat the process of calculating the area using the Field Calculator

The result of this will show very similar measurements for area.

We can calculate the difference between the two measurements using the field calculator.&#x20;

Open the Field Calculator, choose to create a new column called 'diff' with a decimal number data type. In the Expression box, type:

`"area" - "area_eq"`

And click **Ok.** Your resulting table should look like this. The area differences are within 2 square metres.

![](/files/-MjV0U1FgdQSXtvlbzfC)

## Summary

This tutorial has provided a dataset of the locations of the A68 iceberg as it moved towards South Georgia at the end of 2020.&#x20;

It has shown how to calculate the area of the each iceberg polygon in QGIS using an ellipsoid based calculation.&#x20;

It has also demonstrated area calculation using an equal area projection using QGIS.

Remember that in QGIS, the Field Calculator geometry calculation will use calculate the area based on the CRS of the dataset, regardless of what CRS the project is in.

Also remember that you can check whether it is calculating on the CRS of the dataset, or on an ellipsoid model, by querying the project properties dialogue box.&#x20;


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://guides.geospatial.bas.ac.uk/geospatial-tutorials/spatial-analysis/area-calculation-in-qgis.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
