ST_Distance_Spheroid — Returns the shortest distance between 2 lat/long points, using a particular spheroid
PostgreSQL
double ST_Distance_Spheroid(
bytea
PointA, bytea
PointB, integer
SRID)
;
double ST_Distance_Spheroid(
bytea
PointA, bytea
PointB)
;
double ST_Distance_Spheroid(
bytea
PointA, bytea
PointB, varchar
WKT_Spheroid)
;
H2
double
ST_Distance_SpheroidEx(
bytea
PointA, bytea
PointB, integer
SRID)
;
double ST_Distance_Spheroid(
bytea
PointA, bytea
PointB)
;
double ST_Distance_Spheroid(
bytea
PointA, bytea
PointB, varchar
WKT_Spheroid)
;
Returns the shortest distance between 2 lat/long points, 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 points SRID.
The well-known text representation of spatial reference systems provides a standard textual representation for spatial reference system information. |
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 |
---|---|---|---|
- | - | - | - |
SELECT ST_Distance_Sphere(Barcelona,Paris), ST_Distance_Spheroid(Barcelona,Paris), ST_Distance(ST_Transform(Barcelona,25831),ST_Transform(Paris,25831)) as Dist_UTM 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 | st_distance_spheroid | dist_utm --------------------+----------------------+------------------ 831098.439081409 | 830646.42674443 | 830348.883136392 --Calculation of distance in different ellipsoids --H2 SELECT ST_Distance_Spheroid(ga,gb) as distance_hayford1924, ST_Distance_SpheroidEx(ga,gb,25830) as distance_grs80 , ST_Distance_Spheroid(ga,gb,'SPHEROID["WGS 84",6378137,298.257223563]') as distance_wgs84 from (SELECT ST_GeomFromText('POINT(-3.52 41.0)',23030) as ga, ST_GeomFromText('POINT(2.33 48.86)',23030) as gb) as foo; --PostgreSQL SELECT ST_Distance_Spheroid(ga,gb) as distance_hayford1924, ST_Distance_Spheroid(ga,gb,25830) as distance_grs80 , ST_Distance_Spheroid(ga,gb,'SPHEROID["WGS 84",6378137,298.257223563]') as distance_wgs84 from (SELECT ST_GeomFromText('POINT(-3.52 41.0)',23030) as ga, ST_GeomFromText('POINT(2.33 48.86)',23030) as gb) as foo; --Result distance_hayford1924 | distance_grs80 | distance_wgs84 ----------------------+------------------+------------------ 987364.755996404 | 987329.984551754 | 987329.984556481