ST_Length2D_Spheroid — Calculates the 2D length of a Line represented by its latitude/longitude coordinates.
PostgreSQL
geometry
ST_Length2D_Spheroid(bytea
LineString, varchar
Spheroid);
geometry
ST_Length2D_Spheroid(bytea
LineString, integer
SRID);
geometry
ST_Length2D_Spheroid(bytea
LineString);
H2
geometry
ST_Length2D_Spheroid(bytea
LineString, varchar
Spheroid);
geometry
ST_Length2D_SpheroidEx(bytea
LineString, integer
SRID);
geometry
ST_Length2D_Spheroid(bytea
LineString);
Calculates the 2D or 3D length of a Line represented by its latitude/longitude coordinates. Distance is calculated using a particular spheroid. This spheroid can be given by the SRID or by the text, if it's not given this function searches at the geometry SRID.
![]() | |
This function supports GeometryCollections. |
| 2D | 3D | M |
|---|---|---|
![]() | - | - |
| OGC SFS for SQL. 1.1 (1999) | OGC SFS for SQL. 1.1.0 (2005) | OGC SFS for SQL. 1.2.0 (2006) | SQL-MM Part 3 |
|---|---|---|---|
| - | - | - | - |
--PostgreSQL
SELECT ST_Length2D_Spheroid(ga) as length_WGS84,
ST_Length2D_Spheroid( ga,'SPHEROID["GRS_1980",6378137,298.257222101]') as length_GRS80,
ST_Length2D_Spheroid(ga,25830) as length2_GRS80
from (SELECT ST_GeomFromText('LINESTRING(-3.52 41.0,2.33 48.86)',4326) as ga) as foo;
--H2
SELECT ST_Length2D_Spheroid(ga) as length_WGS84,
ST_Length2D_Spheroid( ga,'SPHEROID["GRS_1980",6378137,298.257222101]') as length_GRS80,
ST_Length2D_SpheroidEx(ga,25830) as length2_GRS80
from (SELECT ST_GeomFromText('LINESTRING(-3.52 41.0,2.33 48.86)',4326) as ga) as foo;
--Result
length_wgs84 | length_grs80 | length2_grs80
------------------+------------------+------------------
987329.984556481 | 987329.984551754 | 987329.984551754