Select your cookie preferences

We use essential cookies and similar tools that are necessary to provide our site and services. We use performance cookies to collect anonymous statistics, so we can understand how customers use our site and make improvements. Essential cookies cannot be deactivated, but you can choose “Customize” or “Decline” to decline performance cookies.

If you agree, AWS and approved third parties will also use cookies to provide useful site features, remember your preferences, and display relevant content, including relevant advertising. To accept or decline all non-essential cookies, choose “Accept” or “Decline.” To make more detailed choices, choose “Customize.”

ST_LengthSphere - Amazon Redshift

ST_LengthSphere

ST_LengthSphere returns the length of a linear geometry in meters. For point, multipoint, and areal geometries, ST_LengthSphere returns 0. For geometry collections, ST_LengthSphere returns the total length of the linear geometries in the collection in meters.

ST_LengthSphere interprets the coordinates of each point of the input geometry as longitude and latitude in degrees. For 3DZ, 3DM, or 4D geometries, only the first two coordinates are used.

Syntax

ST_LengthSphere(geom)

Arguments

geom

A value of data type GEOMETRY or an expression that evaluates to a GEOMETRY type.

Return type

DOUBLE PRECISION length in meters. The length computation is based on the spherical model of the Earth whose radius is Earth's mean radius of the World Geodetic System (WGS) 84 ellipsoidal model of the Earth.

If geom is null, then null is returned.

Examples

The following example SQL computes the length of a linestring in meters.

SELECT ST_LengthSphere(ST_GeomFromText('LINESTRING(10 10,45 45)'));
st_lengthsphere ------------------ 5127736.08292556
PrivacySite termsCookie preferences
© 2025, Amazon Web Services, Inc. or its affiliates. All rights reserved.