Basic vector GIS

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.

Beginner2 min read

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
FieldTypeDescription
lu_idtextPolygon identifier.
classtextbuilt-up, cropland, forest, water or scrub.
codeintegerClass code 1 to 5.
yearinteger2019 or 2024.
area_harealEllipsoidal 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
FieldTypeDescription
road_idtextRoad identifier.
nametextRoad name.
classtextprimary, secondary or local.
lanesintegerNumber of lanes.
surfacetextpaved 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

  1. Add Land use 2024 and Roads from the tutorial data.
  1. 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_calc as Field name. Click Run.

    The Calculate area tool with the land-use layer, the ellipsoidal method, hectares and the field name area_calc
    Calculate area adds a field with the area of every polygon.
  1. A new layer with the extra field area_calc is added. Compare it with the area_ha field 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.
  1. Open Calculate length, choose Roads (synthetic), Kilometres as Length units and click Run.
  1. 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, $length and $perimeter give ellipsoidal values in m² and m.