Latitude Longitude Distance Calculator — Haversine Formula
Enter the latitude and longitude of two locations to find the shortest over-surface (great-circle) distance in kilometres, miles and nautical miles, plus the initial bearing and midpoint coordinates.
deg
deg
deg
deg
Shortest path along the surface (haversine formula, R = 6371 km)
- 1
Δφ in radians
(48.8566 − 51.5074) × π ÷ 180 = -0.046265 - 2
Δλ in radians
(2.3522 − -0.1278) × π ÷ 180 = 0.043284 - 3
Haversine parameter a
sin²(-0.04627 ÷ 2) + cos(0.899) × cos(0.8527) × sin²(0.04328 ÷ 2) = 0.0007268Combines latitude and longitude differences into the central haversine identity. - 4
Central angle c (rad)
2 × arctan2(√0.000727, √0.999273) = 0.053925 - 5
Great-circle distance
6371 × 0.053925 = 343.556Multiply the central angle by Earth's mean radius (6371 km).
How does this calculator work?
Distance = 2 x 6371 km x atan2(sqrt(a), sqrt(1-a)), where a = sin2(dLat/2) + cos(lat1) x cos(lat2) x sin2(dLon/2). Enter two decimal-degree coordinates to get the great-circle distance in km, miles and nautical miles, plus the initial bearing and midpoint.
Formula
How this is calculated
The haversine formula calculates the shortest path between two points on the surface of a sphere, called the great-circle distance. Unlike a straight line through the Earth, this is the actual over-surface path that a ship or aircraft follows on a globe. For the intermediate distances typical of everyday use (cities, countries), the formula is accurate to within about 0.3 % because the Earth is not a perfect sphere.
The inputs are decimal-degree coordinates: latitude ranges from -90 deg (South Pole) to +90 deg (North Pole) and longitude from -180 deg (International Date Line west) to +180 deg (east). The formula converts both to radians, computes the angular separation c using the haversine identity, and multiplies by the mean radius of Earth (6371 km). The bearing is the initial compass heading from point 1 toward point 2, and the midpoint is the geodesic midpoint on the great circle.
For very precise geodesy (GPS mapping, aviation) the WGS-84 ellipsoidal model (Vincenty or Karney formulas) is recommended instead, as it accounts for polar flattening. Haversine is accurate enough for planning, travel time estimation and most everyday applications.
Frequently asked questions
Convert degrees-minutes-seconds first: decimal degrees = degrees + minutes/60 + seconds/3600. A latitude of 51 deg 30 min 26 sec N equals 51.5072 deg. South latitudes and West longitudes are negative.
A straight line would pass through the Earth. The great-circle distance is the shortest path along the curved surface — the arc of the largest circle that can be drawn on the sphere through both points. This is the path ships and aircraft actually travel.
It assumes a perfect sphere with radius 6371 km. Real Earth errors are typically under 0.3 % because the polar flattening is only 1/298. For distances under 1000 km this is usually within a few kilometres; for trans-polar routes the Vincenty formula (ellipsoidal) is more precise.
Also known as
TG we-Calculate Editorial Team. (2026). Latitude Longitude Distance Calculator — Haversine Formula [Online calculator]. TG we-Calculate. https://we-calculate.com/calculator/latitude-longitude-distance-calculator
TG we-Calculate Editorial Team. "Latitude Longitude Distance Calculator — Haversine Formula." TG we-Calculate. 2026. https://we-calculate.com/calculator/latitude-longitude-distance-calculator.
TG we-Calculate Editorial Team, "Latitude Longitude Distance Calculator — Haversine Formula," TG we-Calculate, 2026. [Online]. Available: https://we-calculate.com/calculator/latitude-longitude-distance-calculator
@misc{wecalculate_latitude_longitude_distance_calculator, title = {Latitude Longitude Distance Calculator — Haversine Formula}, author = {{TG we-Calculate Editorial Team}}, howpublished = {\url{https://we-calculate.com/calculator/latitude-longitude-distance-calculator}}, year = {2026}, note = {TG we-Calculate} }
Did this calculator help you?
