The formula
Haversine: a = sin²(Δφ/2) + cos φ₁ × cos φ₂ × sin²(Δλ/2)
Distance d = 2R × atan2(√a, √(1 − a)), with mean Earth radius R = 6,371.0 km
Initial bearing θ = atan2(sin Δλ × cos φ₂, cos φ₁ × sin φ₂ − sin φ₁ × cos φ₂ × cos Δλ)
Vincenty's formula iterates on the WGS-84 ellipsoid (a = 6,378,137 m, f = 1/298.257)
DMS to decimal: degrees + minutes/60 + seconds/3,600
Worked example
- New York (40.7128, −74.0060) to London (51.5074, −0.1278):
- Haversine distance = 5,570 km (3,461 miles, 3,008 nautical miles).
- The Vincenty ellipsoidal distance is about 5,585 km.
- Initial bearing 51.2° (northeast); final bearing about 108° on arrival, because the great circle curves.
Distance on a sphere
The shortest path between two points on the Earth's surface is an arc of a great circle, a circle whose centre is the centre of the Earth. The haversine formula calculates this great-circle distance from the latitudes and longitudes of two points, treating the Earth as a sphere with a mean radius of 6,371 km. It's numerically stable for both short and long distances, which made it popular for navigation before computers, and it's still the standard choice in apps and databases where accuracy within about 0.5% is enough.
Vincenty: allowing for the Earth's shape
The Earth isn't a perfect sphere: it bulges at the equator, so its equatorial radius is about 21 km larger than its polar radius. Vincenty's formulae calculate distance on the WGS-84 ellipsoid used by GPS and are accurate to within millimetres. The difference from haversine is usually small, up to about 0.5%, but it matters for surveying, aviation and long-range navigation. The calculator shows both. For nearly antipodal points, on opposite sides of the Earth, Vincenty's method can fail to converge, and the haversine result is then the one to use.
Bearings
The initial bearing is the compass direction you'd set off in from the first point to follow the great circle, measured clockwise from true north. On a long great-circle route, the bearing changes continuously, so the final bearing on arrival is usually different. That's why flights from New York to London head northeast and curve over the Atlantic. Pilots and sailors following a constant compass heading travel along a rhumb line instead, which is longer except along the equator or a meridian. Bearings here are true, not magnetic; add or subtract your local magnetic declination for a compass.
Entering coordinates
You can type coordinates in decimal degrees, such as 51.5074 and −0.1278, or in degrees, minutes and seconds, such as 51° 30′ 26″ N and 0° 7′ 40″ W. North latitudes and east longitudes are positive; south and west are negative, or you can add the letters S and W. Most maps and phones can show coordinates for any point: in Google Maps, for example, right-click or long-press on a location. One degree of latitude is about 111 km, and the fifth decimal place of a decimal degree is about 1 m.
Uses of GPS distance
Great-circle distances are used to estimate flight distances and fuel, calculate shipping routes, find the nearest store or branch in location-based apps, analyse fitness tracker data, geocache and check how far away a thunderstorm or earthquake is. For road trips, actual driving distance is longer because roads aren't straight; our road trip calculator plans fuel and stops. For time differences between two places, use the time zone converter.
Flat-map distances
For short distances on a local map, such as across a town, the Earth's curvature hardly matters and you can treat coordinates as a flat grid, but longitude degrees shrink towards the poles, by a factor of cos(latitude). For planar coordinates on a graph, use our distance and midpoint calculator. To convert a distance measured on a paper map, use the map scale calculator. For sun times at a location, try the sunrise and sunset calculator.