[Math] Difference between Haversine and Euclidean Distance

euclidean-geometry

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.

Best Answer

The haversine formula is an equation important in navigation, giving great-circle distances between two points on a sphere from their longitudes and latitudes.

Using the Pythagorean formula on positions given in latitude and longitude makes as little sense as, say, computing the area of a circle using the formula for a square: although it produces a number, there is no reason to suppose it ought to work.

Most often people answer "no, the Pythagorean theorem only works on a 2D Euclidean plane." Rarely, however, do people mention the effect of scale and location on the sphere on how inaccurate the Pythagorean theorem is.

The basic idea being at very small scales, the surface of a sphere looks very much like a plane. At very large scales, it distances along the surface are more curved and therefore the difference between the incorrect Pythagorean Theorem and the correct Haversine Formula is greater.