Haversine Distance Calculator (Latitude and Longitude)

Quick answer

The latitude and longitude distance calculator finds the great-circle distance between two points on Earth with the haversine formula, from decimal degrees or degrees–minutes–seconds, plus the initial and final bearing, the compass direction, the midpoint and an estimated flight time.

°

Positive north, negative south

°

Positive east, negative west

°

Positive north, negative south

°

Positive east, negative west

Distance
1,033
Initial bearing
226 °
Compass direction
SW
Final bearing on arrival
222.6 °
Midpoint latitude
28.2397 °
Midpoint longitude
70.565 °
Central angle
9.29 °
Flight time at 850 km/h (+30 min for take-off and landing)
1 h 43 min

The shortest route between two places on a globe is not a straight line on a flat map but an arc of a great circle, a circle whose centre is the centre of the Earth. That is why flights from Europe to North America head up over Greenland and why airline routes look curved on ordinary maps.

The haversine formula calculates the length of that arc from the latitudes (φ) and longitudes (λ) of the two points. It stays accurate for tiny and huge distances alike, which made it the navigators’ choice long before computers. Treating Earth as a sphere with the mean radius of 6,371 km gives distances within about 0.5% of the more exact ellipsoid; you can also pick the equatorial or polar radius to see the range.

Enter coordinates as decimal degrees (negative for south and west) or as degrees, minutes and seconds with N/S and E/W. Besides the distance in kilometres, miles or nautical miles, the calculator shows the initial bearing you would set off on, the bearing on arrival (great circles change direction along the way), the geographic midpoint and a rough flight time at a typical cruising speed.

How to use the Haversine Distance Calculator

  1. Coordinates in
  2. Point A latitude: Positive north, negative south
  3. Point A longitude: Positive east, negative west
  4. Point A latitude degrees
  5. minutes
  6. seconds
  7. N / S
  8. Point A longitude degrees
  9. minutes
  10. seconds
  11. E / W
  12. Point B latitude: Positive north, negative south
  13. Point B longitude: Positive east, negative west
  14. Point B latitude degrees
  15. minutes
  16. seconds
  17. N / S
  18. Point B longitude degrees
  19. minutes
  20. seconds
  21. E / W
  22. Earth radius

Results update as you type, every field has its own unit menu, and everything is calculated in your browser.

How it works

Convert both points to radians, compute the haversine term a, then the central angle c = 2·atan2(√a, √(1 − a)); the distance is R·c. Bearings use the spherical forward-azimuth formula and the midpoint lies halfway along the great circle.

Worked example

Lahore (31.5204° N, 74.3587° E) to Karachi (24.8607° N, 67.0011° E): Δφ = −6.6597°, Δλ = −7.3576°. Then a = sin²(−3.32985°) + cos 31.5204° × cos 24.8607° × sin²(−3.6788°) ≈ 0.003375 + 0.7735 × 0.004118 ≈ 0.006558, the central angle is 2·atan2(√a, √(1 − a)) ≈ 9.29° (0.16214 rad) and the distance is 6,371 × 0.16214 ≈ 1,033 km. The plane sets off on a bearing of about 226° (SW) and arrives on about 222.6°.

Length of a degree

Latitude 1° of latitude 1° of longitude
0° 111.2 km 111.2 km
30° 111.2 km 96.3 km
45° 111.2 km 78.6 km
60° 111.2 km 55.6 km
80° 111.2 km 19.3 km

Tips

  • Use decimal degrees (negative for south and west) or the degrees–minutes–seconds fields.
  • Great-circle distances assume a spherical Earth (error under 0.5%).
  • Every field has its own unit menu.
  • Everything is calculated in your browser.

Common mistakes to avoid

  • Swapping latitude and longitude.
  • Forgetting the minus sign for southern and western coordinates.
  • Mixing magnetic and true north for bearings.

Inputs explained

Field What to enter
Coordinates in Choose one: Decimal degrees (−90…90, −180…180), Degrees, minutes, seconds
Point A latitude In °. Positive north, negative south
Point A longitude In °. Positive east, negative west
Point A latitude degrees In °
minutes In ′
seconds In ″
N / S Choose one: N, S
Point A longitude degrees In °
minutes In ′
seconds In ″
E / W Choose one: E, W
Point B latitude In °. Positive north, negative south
Point B longitude In °. Positive east, negative west
Point B latitude degrees In °
minutes In ′
seconds In ″
N / S Choose one: N, S
Point B longitude degrees In °
minutes In ′
seconds In ″
E / W Choose one: E, W
Earth radius Choose one: Mean radius (6,371 km), Equatorial (6,378.137 km), Polar (6,356.752 km)

What each result means

  • Distance = 2×[Earth radius]×atan2(sqrt([a]), sqrt(1 – [a]))
  • Compass direction = mod(round([Initial bearing]÷22.5), 16)
  • Midpoint latitude = deg(atan2(sin(rad([LA1])) + sin(rad([LA2])), sqrt((cos(rad([LA1])) + [bx])^2 + [by]^2)))
  • Midpoint longitude = mod([LO1] + deg(atan2([by], cos(rad([LA1])) + [bx])) + 540, 360) – 180
  • Central angle = deg(2×atan2(sqrt([a]), sqrt(1 – [a])))
  • Flight time at 850 km/h (+30 min for take-off and landing) = [Distance]÷850 + 0.5

Formula

a = sin²(Δφ/2) + cos φ₁ · cos φ₂ · sin²(Δλ/2) · d = 2R · atan2(√a, √(1 − a)) · θ = atan2(sin Δλ · cos φ₂, cos φ₁ · sin φ₂ − sin φ₁ · cos φ₂ · cos Δλ)

Worked example

Inputs: Coordinates in: Decimal degrees (−90…90, −180…180); Point A – latitude: 31.5204 °; Point A – longitude: 74.3587 °; Point B – latitude: 24.8607 °; Point B – longitude: 67.0011 °; Earth radius: Mean radius – 6,371 km.
Results: Distance = 1,033 km; Initial bearing = 226 °; Compass direction = SW; Final bearing on arrival = 222.6 °; Midpoint latitude = 28.2397 °; Midpoint longitude = 70.565 °; Central angle = 9.29 °; Flight time at 850 km/h (+30 min for take-off and landing) = 1 h 43 min.

Key terms

Great circle
The intersection of the Earth's surface with a plane through its centre; the shortest path between two points.
Haversine
hav(θ) = sin²(θ/2), the function that gives the formula its name.
Bearing
The direction of travel measured clockwise from true north, 0–360°.
Central angle
The angle between the two points as seen from Earth's centre.

Frequently asked questions

How do I calculate the distance between two coordinates?

Use the haversine formula: a = sin²(Δφ/2) + cos φ₁ cos φ₂ sin²(Δλ/2), then d = 2R·atan2(√a, √(1 − a)) with R = 6,371 km.

How far is Lahore from Karachi?

About 1,033 km (642 miles) in a straight great-circle line, on an initial bearing of about 226° (south-west).

How accurate is the haversine formula?

Within about 0.5% because Earth is slightly flattened at the poles. For survey-grade results use an ellipsoidal method such as Vincenty's.

How many kilometres is one degree of latitude?

About 111.2 km (69 miles) everywhere. A degree of longitude is 111.2 × cos(latitude) km (about 78.6 km at 45°).

Why does the bearing change along the way?

A great circle crosses each meridian at a different angle (except along the equator or a meridian), so the arrival bearing differs from the departure bearing.

How do I convert degrees, minutes and seconds to decimal degrees?

Decimal = degrees + minutes/60 + seconds/3,600, negative for south or west. Switch the input format to enter DMS directly.

Is the great-circle distance the same as the driving distance?

No. Roads and flight paths are longer, usually by 10–30%.

Sources

  1. Haversine formula: Wikipedia
  2. Great-circle navigation: Wikipedia
  3. NOAA National Geodetic Survey: Inverse and forward geodetic tools

Cite this calculator

Speedy Calculator. (2026). Haversine Distance Calculator (Latitude and Longitude). Speedy Calculator. https://speedycalculator.com/calculators/other/haversine-distance/