Thursday 19 April 2018

gdal - PostGIS ST_Distance in meters discrepancy


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

enter image description here


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


No comments:

Post a Comment

arcpy - Changing output name when exporting data driven pages to JPG?

Is there a way to save the output JPG, changing the output file name to the page name, instead of page number? I mean changing the script fo...