ST_LENGTH()

All functions > GEOSPATIAL > ST_LENGTH()

Returns the length of a linear geometry or geography.

Signatures

Length

Returns: Length of the input

ST_LENGTH(geo: T) → DOUBLE
sql
ParameterTypeRequiredDescription
geoTYesGeometry or geography value

With:

  • T : Custom types: GEOM_POINT | GEOM_LINESTRING | GEOM_POLYGON | GEOM_MULTIPOINT | GEOM_MULTILINESTRING | GEOM_MULTIPOLYGON | GEOM_MULTIANY | GEOG_POINT | GEOG_LINESTRING | GEOG_POLYGON | GEOG_MULTIPOINT | GEOG_MULTILINESTRING | GEOG_MULTIPOLYGON | GEOG_MULTIANY

Signature notes:

  • On GEOMETRY: returns planar length in SRID coordinate units
  • On GEOGRAPHY: returns geodesic length in meters
  • Returns 0.0 for Point, Polygon, MultiPoint, MultiPolygon (not NULL)
  • On GeometryCollection: returns the sum of lengths of linear children
  • Returns NULL if the input is NULL

Examples

Geometry (planar length)

FeatureQL
SELECT
    f1 := ST_LENGTH(ST_GEOMFROMTEXT('LINESTRING (0 0, 3 4)')), -- Length of a 3/4/5 line
    f2 := ST_LENGTH(ST_GEOMPOINT(1.0, 2.0)) -- Length of a point is 0
;
Result
f1 VARCHARf2 VARCHAR
5.00.0

Last update at: 2026/05/26 17:22:09