I am fairly new to this geo distance. My use case is to find short distances as a person walks. So I will have 2 sets of (lat,lon)s. Now to find the distance I could use Euclidean distance easily. Looks like the distance conversion will be like this:
6371000. * Sqrt[dx^2 + dy^2]] * pi / 180 meters
So I wrote a simple code to find out the comparison:
import math
from haversine import haversine
test = [
[lat,lon,lat,lon],
...
[lat,lon,lat,lon]
]
for x in test:
dist = math.hypot(x[2] - x[0], x[3] - x[1]) * 6371000*math.pi/180
hv = haversine(x[0:2],x[2:4])*1000
print('eucledian: %0.3f' % dist, '\thaversine: %0.3f ' % hv, '\toffset: %0.3f' % (hv - dist),'m')
My Results looked like this:
eucledian: 0.127 haversine: 0.111 offset: -0.015 m
eucledian: 0.273 haversine: 0.219 offset: -0.053 m
eucledian: 1.875 haversine: 1.715 offset: -0.159 m
eucledian: 2.460 haversine: 2.387 offset: -0.073 m
eucledian: 0.961 haversine: 0.881 offset: -0.080 m
eucledian: 0.099 haversine: 0.084 offset: -0.016 m
So the question is which one is accurate and what causes the difference? What is the most accurate distance formula to be used? The distance in my case is less than a meter.
hypotthat way. Degrees (and subparts of degrees) are different in longitude and latitude, except right at the equator, because degrees of longitude shrink as you get closer to the poles, and degrees of latitude don't. You need to convert first to rectangular coordinates (in meters), then applyhypotto the difference in x, y, and z coordinates. But are you sure you're meant to be expressing the endpoints of a distance of a few meters in longitude and latitude?! – Brian Tung Oct 30 '18 at 23:05