1

I am comparing the effectiveness of Vincenty formulae and the haversine formula over varying distances of seperation . I would like to know the error rates between them. Is there any cool way to plot these ?

Sayantan Roy
  • 134
  • 1
  • 15

1 Answers1

2

I'm assuming you really want to compare great-circle distances with geodesic distances. Haversine and Vincenty happen to be algorithms for computing such distances; however both result in excessive errors in some limits. See my answer to Is the Haversine Formula or the Vincenty's Formula better for calculating distance?.

I provide a better algorithm for geodesic distances in the Matlab package geographiclib. This also provides accurate great circle distances if the flattening of the ellipsoid is set to 0. Here's a simple illustration of its use plotting the relative and absolute error for a random set of points. This requires that my package be on your Matlab path.

num = 100000;
lat1 = asind(2*rand(num,1)-1);
lat2 = asind(2*rand(num,1)-1);
lon1 = 180*(2*rand(num,1)-1);
lon2 = 180*(2*rand(num,1)-1);
wgs84 = defaultellipsoid;
a = wgs84(1);
b = a * (1 - ecc2flat(wgs84(2)));
sphere = [(2*a + b)/3, 0];
[s12s, azi1s, azi2s] = geoddistance(lat1,lon1,lat2,lon2, sphere);
[s12e, azi1e, azi2e] = geoddistance(lat1,lon1,lat2,lon2, wgs84);
erra = (s12s - s12e);
errr = 100 * erra ./ s12e;
figure(1); plot(s12e, abs(errr), 'x');
figure(2); plot(s12e, abs(erra), 'x');

You might also want to look at my answer to How accurate is approximating the Earth as a sphere?.

Community
  • 1
  • 1
cffk
  • 1,839
  • 1
  • 12
  • 17