I'm trying to figure out what gives me the most accurate distance between positions:
- Measuring distance directly (using
- 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
>>> 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 - p2_projected)**2 + (p1_projected - p2_projected)**2) 894.0253411891856
So, I'm getting
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).