Calculate distance, bearing and midpoint between any two GPS coordinates instantly.

GPS Distance Calculator — Free Online Tool

Great circles and why straight lines are wrong

On a flat surface, the shortest path between two points is a straight line. But Earth is a sphere, so the shortest path is a great circle — the largest circle you can draw on a sphere that passes through both points (and through Earth's centre).

On a standard Mercator map projection, great-circle routes appear as curved lines. A flight from New York to London, for example, curves northward over the North Atlantic rather than heading directly east — because that curved path is actually shorter.

The Haversine formula

The Haversine formula calculates the great-circle distance between two points given their decimal-degree coordinates:

a = sin²(Δlat/2) + cos(lat1) × cos(lat2) × sin²(Δlon/2)
c = 2 × atan2(√a, √(1−a))
d = R × c

Where:

Worked example: Madrid to Paris

Δlat = 48.856613 − 40.416775 = 8.439838° = 0.14733 rad
Δlon = 2.352222 − (−3.703790) = 6.056012° = 0.10572 rad

a = sin²(0.07367) + cos(0.7056) × cos(0.8530) × sin²(0.05286)
  = 0.005427 + 0.7645 × 0.6555 × 0.002794
  = 0.005427 + 0.001662 = 0.007089

c = 2 × atan2(√0.007089, √0.992911) = 2 × atan2(0.08420, 0.99645) = 0.16865 rad

d = 6371.0088 × 0.16865 ≈ 1,074 km

The actual great-circle distance from Madrid to Paris is about 1,074 km (668 mi / 580 NM).

Accuracy of the Haversine formula

The Haversine formula assumes Earth is a perfect sphere. Earth is actually an oblate spheroid (slightly flattened at the poles), which means the Haversine formula has a maximum error of about 0.3% compared to the more complex Vincenty formula, which models Earth as the WGS84 ellipsoid. For everyday navigation and planning, this error (roughly 3 km over 1,000 km) is negligible.

Compass bearing

The bearing is the compass direction from Point A to Point B, measured clockwise from true north:

y = sin(Δlon) × cos(lat2)
x = cos(lat1) × sin(lat2) − sin(lat1) × cos(lat2) × cos(Δlon)
bearing = atan2(y, x) converted to degrees, normalised to 0–360°

Cardinal directions

BearingDirectionBearingDirection
000°N (North)180°S (South)
045°NE (Northeast)225°SW (Southwest)
090°E (East)270°W (West)
135°SE (Southeast)315°NW (Northwest)

Initial bearing vs return bearing

The initial bearing from A to B is the direction you face at A to travel toward B along the great circle. The return bearing (B to A) is calculated by swapping the two points. Because of Earth's curvature, the return bearing is not simply 180° away from the initial bearing — the difference grows with distance and latitude.

For the Madrid–Paris example: initial bearing A→B ≈ 033° (NNE), return bearing B→A ≈ 213° (SSW).

Midpoint between two coordinates

The midpoint is the geographic centre of the great-circle path — the point equidistant from both endpoints. The formula is:

Bx = cos(lat2) × cos(Δlon)
By = cos(lat2) × sin(Δlon)
mid_lat = atan2(sin(lat1) + sin(lat2), √((cos(lat1) + Bx)² + By²))
mid_lon = lon1 + atan2(By, cos(lat1) + Bx)

Note that the midpoint longitude is not simply (lon1 + lon2) / 2, particularly when the path crosses the antimeridian (180° longitude line).

Distance units

Once you have the distance in kilometres, converting to other units is straightforward:

A nautical mile is defined as exactly 1,852 metres, which equals one arcminute of latitude — a convenient relationship for celestial and maritime navigation.

True north vs magnetic north

All GPS bearings (including those in our calculator) are measured from true north — the geographic North Pole. A compass needle points to magnetic north, which is currently about 500 km from the geographic pole and moves over time. The difference at any location is the magnetic declination. For GPS navigation this distinction matters only when using a physical compass alongside GPS coordinates.

Calculate distance, bearing and midpoint for any two GPS coordinates.

Open the GPS Distance Calculator

Related tools