GPS Distance (Haversine)

Great-circle distance between two coordinates, with the bearing you leave on AND the bearing you arrive on.

Run the calculator

Example

You enter

You get

Checked against published worked examples from: National Geospatial-Intelligence Agency.

Details, formula, and sources

ScopeA great circle is the shortest path but it is not a constant heading: the course turns continuously, so the initial bearing is a departure heading rather than something to steer the whole way. New York to Los Angeles leaves on 273.7 degrees and arrives on 245.9, a 27.8 degree swing, which is why a long leg is flown or sailed as a series of shorter rhumb-line legs re-cut along the way. The drift is near zero on a short leg and enormous at high latitude, and it is exactly zero along a meridian, which is itself a great circle.

Formula or tableGreat-circle distance via the haversine formula a = sin²(Δφ/2) + cos(φ1) × cos(φ2) × sin²(Δλ/2); d = 2 × R × atan2(sqrt(a), sqrt(1−a)). R = 6371.0088 km, the IUGG mean earth radius. Initial bearing from atan2(sin(Δλ) cos(φ2), cos(φ1) sin(φ2) − sin(φ1) cos(φ2) cos(Δλ)); FINAL bearing is the reverse leg's initial bearing turned 180 degrees, and the drift between them is reported as a signed shortest-angle difference.

Source and editionClassical spherical trigonometry; WGS84 mean radius.

Free accessHaversine / great-circle derivations are free in navigation texts and at nist.gov and university OCW.

What governsEstimate. AHJ and licensed professional govern.

API field nameslat1, lon1, lat2, lon2, miles

Related tools