Planning a flight route, writing a script to cluster GPS points, verifying a geofence, or just satisfying curiosity about how far apart two cities really are? This coordinate distance calculator does all of that in one step — enter two latitude/longitude pairs and instantly see the great-circle distance, forward and return bearings, and the geographic midpoint, with a full breakdown of every formula step.
How it works
The tool implements the Haversine formula, the standard algorithm for computing the shortest path between two points on a sphere (the great-circle arc). It uses Earth’s mean radius of 6 371.0088 km (WGS-84 spherical approximation).
Given two points with latitudes φ₁, φ₂ and longitudes λ₁, λ₂ (all in radians):
a = sin²((φ₂−φ₁)/2) + cos(φ₁) · cos(φ₂) · sin²((λ₂−λ₁)/2)
c = 2 · asin(√a)
d = R · c
where d is the distance and R = 6 371.0088 km.
The calculator also derives:
- Kilometres, miles and nautical miles — 1 km = 0.621371 mi = 0.539957 nmi.
- Initial (forward) bearing — the compass direction at Point A to head towards Point B, using
atan2(sin(Δλ)·cos(φ₂), cos(φ₁)·sin(φ₂) − sin(φ₁)·cos(φ₂)·cos(Δλ)), mapped to 0–360°. - Return bearing — the direction from B back to A; not simply 180° opposite because great-circle paths curve.
- Geographic midpoint — computed via 3-D Cartesian vector averaging: convert each point to (x, y, z), average, then convert back to latitude/longitude.
Worked example — London to Paris
| Field | Value |
|---|---|
| Point A (London) | 51.5074° N, 0.1278° W |
| Point B (Paris) | 48.8566° N, 2.3522° E |
| Δφ | −2.6508° |
| Δλ | +2.4800° |
| a | 0.00175… |
| c | 0.05291… rad |
| Distance | 337.3 km / 209.6 mi / 182.2 nmi |
| Initial bearing | 148.3° (SSE) |
| Return bearing | 328.9° (NNW) |
| Midpoint | ~50.18° N, 1.12° E |
The forward bearing of ~148° is south-south-east from London, which matches looking at a map. The return bearing of ~329° is north-north-west from Paris back to London.
Why Haversine and not flat-Earth Pythagoras?
For small distances (under ~20 km) the Euclidean approximation is acceptable, but errors compound rapidly as distances grow. London to New York is roughly 5 570 km; treating the Earth as flat gives a result that is off by hundreds of kilometres. The Haversine formula accounts for the curvature of the Earth and stays accurate to within 0.5% for all distances, which is far better than GPS accuracy for most applications.
Formula note
The “Haversine” name comes from the trigonometric identity hav(θ) = sin²(θ/2), which avoids the numerical instability of earlier spherical-law-of-cosines approaches at very short distances. The formula was popularised for navigation in the 19th century and remains the go-to method in GIS, GPS firmware, and spatial databases (PostGIS uses it internally for ST_DistanceSphere).