Name

ST_Distance_Sphere — Returns distance between 2 lat/long points. It is the great-circle distance, also known as or orthodromic, which is the shortest distance between any two points on the surface of a sphere measured along a path on the surface of the sphere

Synopsis

double ST_Distance_Sphere(bytea PointA, bytea PointB);

Alias

Distance_Sphere

Description

Returns distance between 2 lat/long points. It is the great-circle distance, also known as or orthodromic, which is the shortest distance between any two points on the surface of a sphere measured along a path on the surface of the sphere.

Earth radius 6370986.884258304

Distance is calculated by the harvesine formula. See Wikipedia great circle distance for more information.

Where Δσ is the spherical distance, ФS λS are the start point Latitude and Longitude, ФF λF are the final point Latitude and Longitude.

And finally to obtain the linear distance, the next equation is applied (r = Earth radius 6370986.884258304):

[Caution]

This function only works with Points

Coordinate Dimensions
2D3DM
Spatial Standards Support
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
----

Examples

SELECT ST_Distance_Sphere(Barcelona,Paris) 
 from (SELECT ST_GeomFromText('POINT(2.183333 41.383333)',4326) as Barcelona, 
              ST_GeomFromText('POINT(2.350833 48.856667)',4326) as Paris) as foo;

 st_distance_sphere
--------------------
   831098.439081409

Related functions

ST_Distance,ST_Distance_Spheroid