Name

ST_Length — Returns the 2D length of the geometry if it is a LineString or MultiLineString. geometry are in units of spatial reference and geography are in meters (default spheroid)

Synopsis

float ST_Length(geometry a_2dlinestring);

float ST_Length(geography geog, boolean use_spheroid=true);

Description

For geometry: Returns the 2D Cartesian length of the geometry if it is a LineString, MultiLineString, ST_Curve, ST_MultiCurve. 0 is returned for
areal geometries. For areal geometries use ST_Perimeter. For geometry types, units for length measures are specified by the
spatial reference system of the geometry.

For geography types, the calculations are performed using the inverse geodesic problem, where length units are in meters.
If PostGIS is compiled with PROJ version 4.8.0 or later, the spheroid is specified by the SRID, otherwise it is exclusive to WGS84.
If use_spheroid=false, then calculations will approximate a sphere instead of a spheroid.

Currently for geometry this is an alias for ST_Length2D, but this may change to support higher dimensions.

Changed: 2.0.0 Breaking change -- in prior versions applying this to a MULTI/POLYGON of type geography would give you the perimeter of the POLYGON/MULTIPOLYGON. In 2.0.0
this was changed to return 0 to be in line with geometry behavior. Please use ST_Perimeter if you want the perimeter of a polygon

For geography measurement defaults spheroid measurement. To use the faster less accurate sphere use ST_Length(gg,false);