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.
Answer
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
CC BY-SA 3.0, Author: Stefan Kühn
No comments:
Post a Comment