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¶ST_LENGTH( <geography_or_geometry_expression> )
Copy
Arguments¶geography_or_geometry_expression
The argument must be of type GEOGRAPHY or GEOMETRY.
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.
If geography_or_geometry_expression
is not a LineString, MultiLineString, or GeometryCollection containing linestrings, ST_LENGTH returns 0.
If geography_or_geometry_expression
is 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.
This shows the length in meters of one degree of arc at the equator:
GEOMETRY examples¶SELECT ST_LENGTH(TO_GEOGRAPHY('LINESTRING(0.0 0.0, 1.0 0.0)')); +---------------------------------------------------------+ | ST_LENGTH(TO_GEOGRAPHY('LINESTRING(0.0 0.0, 1.0 0.0)')) | |---------------------------------------------------------| | 111195.101177484 | +---------------------------------------------------------+Copy
The following example demonstrates how to use the ST_LENGTH function.
SELECT ST_LENGTH(g), ST_ASWKT(g) FROM (SELECT TO_GEOMETRY(column1) AS g FROM VALUES ('POINT(1 1)'), ('LINESTRING(0 0, 1 1)'), ('POLYGON((0 0, 0 1, 1 1, 1 0, 0 0))'));Copy
+--------------+--------------------------------+ | ST_LENGTH(G) | ST_ASWKT(G) | |--------------+--------------------------------| | 0 | POINT(1 1) | | 1.414213562 | LINESTRING(0 0,1 1) | | 0 | POLYGON((0 0,0 1,1 1,1 0,0 0)) | +--------------+--------------------------------+Copy
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4