Skip to main content

ST_LENGTH

Introduced or updated: v1.2.555

Returns the Euclidean length of the LineString(s) in a GEOMETRY or GEOGRAPHY object.

Syntax

ST_LENGTH(<geometry_or_geography>)

Arguments

ArgumentsDescription
<geometry_or_geography>The argument must be an expression of type GEOMETRY or GEOGRAPHY containing linestrings.
note
  • If <geometry_or_geography> is not a LineString, MultiLineString, or GeometryCollection containing linestrings, returns 0.
  • If <geometry_or_geography> is a GeometryCollection, returns the sum of the lengths of the linestrings in the collection.

Return Type

Double.

Examples

GEOMETRY examples

SELECT
ST_LENGTH(TO_GEOMETRY('POINT(1 1)')) AS length

┌─────────┐
│ length │
├─────────┤
0
└─────────┘

SELECT
ST_LENGTH(TO_GEOMETRY('LINESTRING(0 0, 1 1)')) AS length

┌─────────────┐
│ length │
├─────────────┤
1.414213562
└─────────────┘

SELECT
ST_LENGTH(
TO_GEOMETRY('POLYGON((0 0, 0 1, 1 1, 1 0, 0 0))')
) AS length

┌─────────┐
│ length │
├─────────┤
0
└─────────┘

GEOGRAPHY examples

SELECT
ST_LENGTH(
ST_GEOGFROMWKT(
'LINESTRING(0 0, 1 0)'
)
) AS length

╭──────────────────╮
│ length │
├──────────────────┤
111319.490793274
╰──────────────────╯
Try Databend Cloud for FREE

Multimodal, object-storage-native warehouse for BI, vectors, search, and geo.

Snowflake-compatible SQL with automatic scaling.

Sign up and get $200 in credits.

Try it today