Calculating area, length and perimeter attributes
Add the area of polygons, the length of lines and the perimeter as new fields, with ellipsoidal or planar measurement and the units you choose.
You will learn
- Add area, length and perimeter fields to a layer.
- Choose between ellipsoidal and planar measurement.
- Use $area and $length in expressions.
Prerequisites
Data for this tutorial
Land use 2019 and 2024 (synthetic) Download landuse_2024.geojson
- Format
- GeoJSON (also landuse_2019.geojson)
- Geometry
- Polygon
- CRS
- EPSG:32643 (WGS 84 / UTM zone 43N)
- Content
- 61 polygons (2024), 50 polygons (2019)
- In Orbis
- Browser panel ▸ Tutorial sample data (synthetic) ▸ Land use 2024, or Load complete tutorial pack.
Fields used in the tutorials
| Field | Type | Description |
|---|---|---|
lu_id | text | Polygon identifier. |
class | text | built-up, cropland, forest, water or scrub. |
code | integer | Class code 1 to 5. |
year | integer | 2019 or 2024. |
area_ha | real | Ellipsoidal area in hectares. |
Roads (synthetic) Download roads.geojson
- Format
- GeoJSON
- Geometry
- LineString
- CRS
- EPSG:32643 (WGS 84 / UTM zone 43N)
- Content
- 23 roads: 2 primary, 5 secondary, 16 local
- In Orbis
- Browser panel ▸ Tutorial sample data (synthetic) ▸ Roads, or Load complete tutorial pack.
Fields used in the tutorials
| Field | Type | Description |
|---|---|---|
road_id | text | Road identifier. |
name | text | Road name. |
class | text | primary, secondary or local. |
lanes | integer | Number of lanes. |
surface | text | paved or unpaved. |
Licence: CC0 1.0. All tutorial data is synthetic and generated by Orbis. About the datasets
The task
You need the area of every land-use polygon in hectares and the length of every road in kilometres, stored as fields so that you can sort, filter and summarise them.
Steps
- Add Land use 2024 and Roads from the tutorial data.
In the Toolbox, open Calculate area. Choose Land use 2024 (synthetic) as Input layer, keep Measurement method at Ellipsoidal (WGS 84 geodesic, any CRS), choose Hectares as Area units and type
area_calcas Field name. Click Run.
Calculate area adds a field with the area of every polygon.
- A new layer with the extra field
area_calcis added. Compare it with thearea_hafield the dataset already has: the values agree to within 0.01 ha (the stored field is rounded to two decimals), because both are ellipsoidal areas.
- Open Calculate length, choose Roads (synthetic), Kilometres as Length units and click Run.
- Add geometry attributes adds several measures at once (area and perimeter for polygons, length for lines, X and Y for points).
Expected result
The new land-use layer has an area_calc field in hectares; the land-use polygons of 2024 add up to about 10,509.4 ha. The new roads layer has a length field in kilometres.
Common mistakes
- Planar areas in degrees. In a CRS such as EPSG:4326 the planar method is refused because a square degree is not an area. Use the ellipsoidal method.
- Confusing units. 1 km² = 100 ha = 1,000,000 m².
Troubleshooting
- The value is empty (NULL). The feature has no geometry, or the geometry is invalid. Check the layer with Check validity.
- I want the area in an expression. In the Field calculator and in expressions,
$area,$lengthand$perimetergive ellipsoidal values in m² and m.