PostgreSQL's ST_Distance_Sphere function calculates the distances on earth:

float ST_Distance_Sphere(geometry pointlonlatA, geometry pointlonlatB);

In its documentation, there is a peculiar note:

This function currently does not look at the SRID of a point geometry and will always assume its in WGS 80 long lat.

My geometries are stored in WGS 84, which seems to be the de-facto standard for storing geospatial entities in PostgreSQL, an the reference coordinate system used by the GPS system.

Why does ST_Distance_Sphere uses WGS 80? Should I expect any significant error due to the coordinate system difference?

3 Answers 3


It doesn't use WGS80. You are looking at old documentation for version 1.4. In more up to date documentation it states WGS84 is assumed. See here where it states:

This function currently does not look at the SRID of a geometry and will always assume its in WGS 84 long lat.

The version you quote from (1.4) also only implemented ST_Distance_Sphere for points (being prior to 1.5). The documentation since 1.4 all states that WGS84 is used. I suspect that the reference to 'WGS80' in the v1.4 documentation is a typo. I know of WGS60, WGS66 and WGS72. There is a GRS80 but I'm unaware of a WGS80 (confirmed with a quick check on spatialreference.org)

In any event, the speed of st_distance_sphere over st_distance_spheroid comes from the the former's use of approximating a spherical Earth of radius 6370986 meters (which has been the same since v1.3 - which is another reason why I suspect a typo). So use st_distance_sphere for speed and st_distance_spheroid for greater accuracy.

  • 2
    Not really that silly as I think it is a typo (see my edits)! Better to ask than remain confused! Jul 16, 2015 at 6:54
  • WGS84 is only assumed if there is no SRID see Mike T's answer below: gis.stackexchange.com/a/154769/6052 the docs are still wrong and Mike T is correct. Nov 20, 2017 at 21:35

The postgis 2.1 manual states that it assumes WGS84. And uses a sphere to return a faster result than ST_Distance_Spheroid which returns the minimum distance between two lon/lat geometries given a particular spheroid.


Actually, the manual is incorrect. If the SRID is unknown, it is assumed to be WGS84. For PostGIS 2.0 and later, the radius of the spheroid is obtained by calculating the average mean radius with the data provided by the SRID. Let's add a Martian projection system for fun:

SELECT Postgis_version()
INSERT INTO spatial_ref_sys (srid, auth_name, auth_srid, proj4text, srtext) VALUES
(49900, 'IAU2000', 49900, '+proj=longlat +a=3396190 +b=3376200 +no_defs ', 'GEOGCS["Mars 2000",DATUM["D_Mars_2000",SPHEROID["Mars_2000_IAU_IAG",3396190.0,169.89444722361179]],PRIMEM["Greenwich",0],UNIT["Decimal_Degree",0.0174532925199433]]');

Now calculate some distances 1°W of Null Island:

  ST_Distance_Sphere(p1, p2) AS default,
  ST_Distance_Sphere(ST_SetSRID(p1, 4326), ST_SetSRID(p2, 4326)) AS wgs_84,
  ST_Distance_Sphere(ST_SetSRID(p1, 4269), ST_SetSRID(p2, 4269)) AS grs_1980,
  ST_Distance_Sphere(ST_SetSRID(p1, 49900), ST_SetSRID(p2, 49900)) AS mars
    SELECT ST_MakePoint(0, 0) AS p1, ST_MakePoint(0, 1) AS p2
) f;
-[ RECORD 1 ]--------------
default  | 111195.079734632
wgs_84   | 111195.079734632
grs_1980 | 111195.079734022
mars     | 59158.400417482

So you can see that there are very minor differences between WGS84 and GRS80. Obviously Mars has a different radius than Earth.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.