# Measure area and length

Model / geo

A variant of [Work with geography](https://meridian.online/operations/work-with-geography).

Compute the area, length or perimeter of each geometry.

Page: <https://meridian.online/operations/work-with-geography/measure-area-and-length>

## Status

Runs as a SQL step.

arcform carries it as a `sql:` step today, with the `spatial` extension.

## The DuckDB step

measure the area, length and perimeter of each geometry

```sql
INSTALL spatial; LOAD spatial; SET geometry_always_xy = true;

CREATE TEMP TABLE shapes AS SELECT * FROM (VALUES
  ('rectangle', ST_GeomFromText('POLYGON ((0 0, 4 0, 4 3, 0 3, 0 0))')),
  ('with hole', ST_GeomFromText('POLYGON ((0 0, 10 0, 10 10, 0 10, 0 0), (2 2, 4 2, 4 4, 2 4, 2 2))')),
  ('road', ST_GeomFromText('LINESTRING (0 0, 3 4, 3 10)')),
  ('degree box', ST_GeomFromText('POLYGON ((0 0, 1 0, 1 1, 0 1, 0 0))'))) t(name, geom);
-- planar measures in the units of the coordinates; area and perimeter are zero for a line and length is zero for a polygon
CREATE TEMP TABLE planar AS SELECT name, ST_Area(geom) AS area, ST_Length(geom) AS length, ST_Perimeter(geom) AS perimeter FROM shapes;
-- on the earth: the same box in degrees, measured on the WGS84 ellipsoid in metres
CREATE TEMP TABLE on_earth AS SELECT ST_Area_Spheroid(geom) AS area_m2, ST_Perimeter_Spheroid(geom) AS perimeter_m, ST_Length_Spheroid(ST_GeomFromText('LINESTRING (0 0, 1 0)')) AS equator_degree_m FROM shapes WHERE name = 'degree box';
SELECT * FROM planar ORDER BY name;
SELECT * FROM on_earth;
-- the spheroid values are those of geographiclib on the same box: area 12308778361.469452 m2, perimeter 443770.91724830196 m
SELECT CASE WHEN ((SELECT area = 12 AND perimeter = 14 FROM planar WHERE name = 'rectangle')
  AND (SELECT area = 96 AND perimeter = 48 FROM planar WHERE name = 'with hole')
  AND (SELECT length = 11 AND area = 0 FROM planar WHERE name = 'road')
  AND (SELECT abs(area_m2 - 12308778361.469452) < 1e-3 AND abs(perimeter_m - 443770.91724830196) < 1e-6 AND abs(equator_degree_m - 111319.49079327357) < 1e-6 FROM on_earth)) THEN 'as expected' ELSE error('the rectangle should measure 12 and 14, the polygon with a hole 96 and 48, the road 11 long, and the one-degree box 12308778361 m2 on the ellipsoid') END AS verdict;
```

The statement builds its own data.

It needs the `spatial` extension.

## What other tools call it

Meridian's classification; an independent blind rating agreed on 95.7% of 324 rows (variant, version 3).

- Alteryx Designer: [`Spatial Info`](https://help.alteryx.com/current/en/designer/tools/spatial/spatial-info-tool.html) (read 2026-09-27)
- Duckle: [`Spatial Area`](https://github.com/slothflowlabs/duckle/blob/f85f8960edfb6efbf4cb89d58a7b32e16df0e867/frontend/src/workflow-ui/palette-data.ts) (read 2026-09-25)
- Duckle: [`Spatial Length`](https://github.com/slothflowlabs/duckle/blob/f85f8960edfb6efbf4cb89d58a7b32e16df0e867/frontend/src/workflow-ui/palette-data.ts) (read 2026-09-25)
- Duckle: [`Spatial Perimeter`](https://github.com/slothflowlabs/duckle/blob/f85f8960edfb6efbf4cb89d58a7b32e16df0e867/frontend/src/workflow-ui/palette-data.ts) (read 2026-09-25)
- Ibis: [`GeoArea`](https://github.com/ibis-project/ibis/blob/05d2b293344e86cb41c1a426071734f7e270335a/ibis/expr/operations/geospatial.py) (read 2026-09-27)
- Ibis: [`GeoLength`](https://github.com/ibis-project/ibis/blob/05d2b293344e86cb41c1a426071734f7e270335a/ibis/expr/operations/geospatial.py) (read 2026-09-27)
- Ibis: [`GeoPerimeter`](https://github.com/ibis-project/ibis/blob/05d2b293344e86cb41c1a426071734f7e270335a/ibis/expr/operations/geospatial.py) (read 2026-09-27)
