- Categories:
ST_ LENGTH¶
Returns the great circle length of the LineString(s) in a GEOGRAPHY object or the Euclidean length of the LineString(s) in a GEOMETRY object.
Syntax¶
Arguments¶
geography_or_geometry_expressionThe argument must be of type GEOGRAPHY or GEOMETRY.
Returns¶
Returns a REAL value, which represents the length:
- For GEOGRAPHY input values, the length is in meters.
- For GEOMETRY input values, the length is computed with the same units used to define the input coordinates.
Usage notes¶
- If
geography_or_geometry_expressionis not a LineString, MultiLineString, or GeometryCollection containing linestrings, ST_LENGTH returns 0. - If
geography_or_geometry_expressionis a GeometryCollection, ST_LENGTH returns the sum of the lengths of the linestrings in the collection. - If you want the perimeter length of a polygon, use the ST_PERIMETER function instead.
Examples¶
GEOGRAPHY examples¶
This shows the length in meters of one degree of arc at the equator:
GEOMETRY examples¶
The following example demonstrates how to use the ST_LENGTH function.