3

Could someone please explain why there is such a significant difference between the results of this query:

SELECT 
    ST_Distance(ST_Transform(previous_geom,3857), ST_Transform(current_geom,3857)) AS distance_transform_exp,
    ST_Distance(previous_geom::geography, current_geom::geography) AS distance_geometry_exp
FROM
(
    SELECT 
        ST_SetSRID(ST_MakePoint(-111.9096893, 40.7411742),4326) AS previous_geom,
        ST_SetSRID(ST_MakePoint(-111.9092079, 40.74135181),4326) AS current_geom
) points_table

Results:

 distance_transform_exp | distance_geometry_exp
+-----------------------+-----------------------
       59.6050787601899 |           45.19182216
(1 row)

I understand there would be a difference between geometric (Cartesian) calculation results and geodetic (spheroid) alas for the example points which are relatively close, the discrepancy would be expected to be negligible.

5

Although the question is different, the answer is the same as this one.


ST_Distance(previous_geom::geography, current_geom::geography) is the correct result.

WGS 84 / Pseudo-Mercator (EPSG:3857) projection is heavily distorted when moving away from the equator. Thus, it could be discussed if the units should be called "Pseudo-meters". One meter in reality is approximately 1/cos(lat) pseudo-meters.

45.19 m / cos(40.7°) = 59.6 pseudo-meters

enter image description here

CC BY-SA 3.0, Author: Stefan Kühn

  • so distances should never be measured in 3857? – ziggy Dec 11 '17 at 15:18
  • Exactly. Better to use postgis' geography type or the local standard CRS, e.g. the UTM zones. – pLumo Dec 11 '17 at 15:20
  • 1
    The pictures are 3857 but not the measurements probably ... – pLumo Dec 11 '17 at 15:26
  • 1
    It is flat but it is made flat by stretching the world balloon very heavily near the poles. Meter was meter only before the stretch. – user30184 Dec 11 '17 at 15:43
  • 1
    The only "latitude of true scale" in a mercator projection is at the equator. So you can do direct planar calculations as long as your working area is (a) small and (b) at the equator. If you're willing to scale your results by 1/cos(phi) you can do direct planar calculations as long as (a) your area of interest is small (b) you remember to scale your result. – Paul Ramsey Dec 11 '17 at 16:57

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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