Note
Access to this page requires authorization. You can try signing in or changing directories.
Access to this page requires authorization. You can try changing directories.
Applies to: Databricks Runtime 17.1 and above
Important
This feature is in Public Preview.
Returns the length of the input GEOGRAPHY
or GEOMETRY
value.
Syntax
st_length ( geoExpr )
Arguments
geoExpr
: AGEOGRAPHY
orGEOMETRY
value.
Returns
A value of type DOUBLE
, representing the length of the input GEOGRAPHY
or GEOMETRY
value.
If the input is a GEOGRAPHY
value, the function returns the 2D geodesic length of the linear part of the GEOGRAPHY
value.
Specifically, the function returns the geodesic length for linestrings, and the sum of the lengths of the linestrings in a multilinestring.
For non-linear geographies (points, polygons, multipoints, and multipolygons) 0 is returned, whereas for geometry collections the function returns the sum of the lengths of the elements in the collection.
The result is computed by performing the inverse geodesic calculation assuming the WGS84 ellipsoid.
The units of the result is meters.
If the input is a GEOMETRY
value, the function returns the 2D Cartesian length of the linear part of the GEOMETRY
value.
Specifically, the function returns the 2D Cartesian length for linestrings, and the sum of the
lengths of the linestrings in a multilinestring.
For non-linear geometries (points, polygons, multipoints, and multipolygons) 0 is returned, whereas for geometry collections it returns the sum of the lengths of the elements in the collection.
The units of the result are those of the spatial reference system of the input GEOMETRY
value.
The function returns NULL
if any of the inputs is NULL
.
Examples
-- Returns the length of a 2D Cartesian linestring.
> SELECT round(st_length(st_geomfromtext('LINESTRING(10 34,44 57,30 24)')), 8)
76.89564816