Skip to main content

ST_LENGTH

Introduced or updated: v1.2.555

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

Syntax

ST_LENGTH(<geometry>)

Arguments

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

Return Type

Double.

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
└─────────┘
Did this page help you?
Yes
No
Explore Databend Cloud for FREE
Low-cost
Fast Analytics
Easy Data Ingestion
Elastic Scaling
Try it today