Calculate the haversine distance between two latitude and longitude points in km, miles and nautical miles, with bearings, midpoint and destination point.

Find the shortest spherical distance, bearings and midpoint between two coordinates.

Decimal degrees. North is positive; south is negative.

East is positive; west is negative.

Optional settings
Blank uses a mean Earth radius of 6371.0088 km. A custom radius changes the spherical model.


Related Calculators

Calculator Functions

FunctionWhat it doesWhat it requires
Distance and bearingsFinds the great-circle distance between two coordinates, with the initial bearing, final bearing and midpointRequires the latitude and longitude of point A and point B in decimal degrees
Destination coordinatesFinds the latitude and longitude reached by travelling a set distance along a starting bearingRequires the starting latitude and longitude, an initial bearing in degrees and a distance in km, mi or nmi

North latitudes and east longitudes are positive, and south and west are negative. Bearings are measured clockwise from true north. The one optional setting is the sphere radius, which is a mean Earth radius of 6,371.0088 km when left blank. The distance is shown in kilometers, miles, nautical miles and meters, using 1 mi = 1.609344 km and 1 nmi = 1.852 km [2].

Haversine Distance Formulas

a = sinยฒ(ฮ”ฯ† รท 2) +
cos ฯ†1 ร— cos ฯ†2 ร—
sinยฒ(ฮ”ฮป รท 2)
d = 2 ร— R ร— arcsin(โˆša) [1]
dGreat-circle distance, in the units of R
RSphere radius, 6,371.0088 km by default
ฯ†1, ฯ†2Latitudes of points A and B, in radians
ฮ”ฯ†ฯ†2 โˆ’ ฯ†1
ฮ”ฮปLongitude of B minus longitude of A, in radians

Degrees are converted to radians by multiplying by ฯ€ รท 180. The quantity 2 ร— arcsin(โˆša) is the central angle between the two points, and multiplying it by the radius gives the distance along the surface. The same angle can be found from cos c = sin ฯ†1 sin ฯ†2 + cos ฯ†1 cos ฯ†2 cos ฮ”ฮป, but that form loses accuracy when the points are close together, while the haversine form stays accurate from zero to nearly 180ยฐ [1].

Distance and bearings

For A at 40ยฐ, โˆ’75ยฐ and B at 35ยฐ, โˆ’80ยฐ: ฮ”ฯ† = โˆ’5ยฐ and ฮ”ฮป = โˆ’5ยฐ, so a = sinยฒ(โˆ’2.5ยฐ) + cos 40ยฐ ร— cos 35ยฐ ร— sinยฒ(โˆ’2.5ยฐ) = 0.003097. The central angle is 2 ร— arcsin(โˆš0.003097) = 6.380ยฐ, or 0.11135 radians, and d = 6,371.0088 ร— 0.11135 = 709.42 km (440.81 mi, 383.06 nmi).

tan ฮธ = sin ฮ”ฮป ร— cos ฯ†2 รท
(cos ฯ†1 ร— sin ฯ†2 โˆ’
sin ฯ†1 ร— cos ฯ†2 ร— cos ฮ”ฮป) [1]

ฮธ is the initial bearing from A toward B, placed in the correct quadrant and given from 0ยฐ to 360ยฐ. In the example it is 219.98ยฐ, or southwest. A great circle changes direction as it goes, so the final bearing on arrival is different: 216.93ยฐ here. The final bearing is the bearing from B back to A, turned by 180ยฐ. The midpoint is the point halfway along the path, 37.5263ยฐ, โˆ’77.5838ยฐ in the example. For two identical points or two points exactly opposite each other on the globe, the bearings are undefined, and the midpoint of opposite points is not unique.

Destination coordinates

ฯ†2 = arcsin(sin ฯ†1 ร— cos c +
cos ฯ†1 ร— sin c ร— cos ฮธ)
ฮป2 = ฮป1 + arctan(sin c ร—
sin ฮธ รท (cos ฯ†1 ร— cos c โˆ’
sin ฯ†1 ร— sin c ร— cos ฮธ)) [1]

c is the distance travelled divided by the radius, which is the angle covered in radians, and ฮธ is the initial bearing. Starting at 40ยฐ, โˆ’75ยฐ and going 100 km due east (90ยฐ) ends at 39.9941ยฐ, โˆ’73.8261ยฐ. The latitude drops slightly because a great circle heading east curves toward the equator. Travelling 60 nautical miles due north from 0ยฐ, 0ยฐ ends at 0.9993ยฐ, 0ยฐ, close to one degree of latitude. A nonzero trip cannot start exactly at a pole, where every direction is south or north and a bearing has no meaning.

Limits of This Estimate

  • The Earth is treated as a perfect sphere. The real Earth is slightly flattened, so survey-grade distances are computed on an ellipsoid and differ slightly from a spherical result.
  • The distance is the shortest path over the surface, not a driving or sailing route, and it ignores altitude.
  • Entering a custom radius changes the sphere. A radius of 6,371 km gives 709.4193 km for the example above, about one meter less than the default.

Sources

  1. U.S. Geological Survey, Map Projections: A Working Manual (Professional Paper 1395), equations 5-3 to 5-6: great-circle distance in haversine form, the azimuth between two points, and the latitude and longitude at a given distance and azimuth
  2. NIST, Guide for the Use of the International System of Units (SP 811), Appendix B.8: meters in a mile and in a nautical mile