Distance Between Two Airports

Airports MS Access Database Buy it for $39.95
Airports MS SQL Server Database Buy it for $39.95
Airports MySQL Server Database Buy it for $39.95
    There are at least five methods to calculate the distances of points on earth:
  • Pythagorean Theorem
  • Polar Coordinate Flat-Earth Formula
  • Haversine Formula
  • Law of Cosines for Spherical Trigonometry
  • Driving Distance Calculator
  • Let's look at each one.

Pythagorean Theorem

It assumes that meridians are parallel:

d = square root((X2 - X1)^2 + (Y2 - Y1)^2)

Polar Coordinate Flat-Earth Formula

Computationally, it is a little more expensive than the Pythagorean Theorem but it gives smaller maximum errors for higher latitudes and greater distances.

a = pi/2 - lat1
b = pi/2 - lat2
c = square root( a^2 + b^2 - 2 * a * b * cosine(lon2 - lon1) )
d = R * c
where
R = 6371 km - 3960 miles (Earth radius)
pi = 3.14159... (mathematical constant)

Haversine Formula

Assuming a spherical Earth with radius R, and the locations of the two points in spherical coordinates:

dlon = lon2 - lon1
dlat = lat2 - lat1
a = (sin(dlat/2))^2 + cos(lat1) * cos(lat2) * (sin(dlon/2))^2
c = 2 * atan2( sqrt(a), sqrt(1-a) )
d = R * c
where
R = 6371 km - 3960 miles (Earth radius)
pi = 3.14159... (mathematical constant)

Law of Cosines for Spherical Trigonometry

a = sin(lat1) * sin(lat2)
b = cos(lat1) * cos(lat2) * cos(lon2 - lon1)
c = arccos(a + b)
d = R * c
where
R = 6371 km - 3960 miles (Earth radius)
pi = 3.14159... (mathematical constant)

Driving Distance Calculator

There is no formula to calculate the driving distance between two locations. Some companies like Falcon Solution are developing some modules which saved distances between zip codes - like a graph. The graph is then parsed.