[GIS] the real distance between positions

coordinate systemdistancepyprojpython

I'm trying to figure out what gives me the most accurate distance between positions:

  • Measuring distance directly (using Geod.inv)?
  • Measuring distance in 2D (after transforming to a known projected coordinate reference system)?

I'm trying to project latitude/longitude positions to 2D because it is easier to work with them that way, I'm trying to work with centimeter accuracy.

As a sanity check I did some tests to check if distance between positions were preserved.

Here is an interesting data point
(note: I'm actually using DotSpatial library but I re-did this example in pyproj because it is a better-known tool):

Measuring distance "directly" (using geod.inv):

>>> from pyproj import Geod
>>> wgs84_geod = Geod(ellps='WGS84')
>>> lat1, lon1 = (27.23150120120691, -91.522575364888709) # somewhere in the gulf of mexico
>>> lat2, lon2 = (27.239416154284083, -91.520817319790083) # near lat1, lon1
>>> az12,az21,dist = wgs84_geod.inv(lon1,lat1,lon2,lat2)
>>> dist
894.1531771043997

Measuring distance in 2D (after projecting):

>>> from pyproj import Proj
>>> wgs84 = Proj('+proj=longlat +datum=WGS84 +no_defs') # http://epsg.io/4326
>>> nad27Blm15n = Proj('+proj=tmerc +lat_0=0 +lon_0=-93 +k=0.9996 +x_0=500000.001016002 +y_0=0 +datum=NAD27 +no_defs') # http://epsg.io/32065 but in meters
>>> from pyproj import transform
>>> p1_projected = transform(wgs84, nad27Blm15n, lon1, lat1)
>>> p2_projected = transform(wgs84, nad27Blm15n, lon2, lat2)
>>> p1_projected
(646301.4612381, 3012741.116573205)
>>> p2_projected
(646465.2249033558, 3013620.015186602)
>>> import math
>>> math.sqrt((p1_projected[0] - p2_projected[0])**2 + (p1_projected[1] - p2_projected[1])**2)
894.0253411891856

So, I'm getting 894.1531771043997 and 894.0253411891856 respectively which have about 0.128 meters difference.

Which one is the most correct distance? Why?

(note: I also have examples where the differences are > 1m, but only when the distances are > 2km).

Best Answer

All projections change the distances, projections can preserve angles or areas only. If the distortion caused by the projection is less then 10 cm/km considered a very good projection. The real distance is very hypothetical, if you measure the slope distance between two points the slope distance will be reduced to the horizontal plane, then to the see level and finally to the projection plane to display on the map. So we have slope distance, horizontal distance, see level distance and distance on the projection plane. Which would you call 'most correct'?

geod.inv gives the see level distance, the sqrt(..) gives the distance on the projection plane. The longer the distance, the longer the difference.