acalculator

Distance between two places

Enter the latitude and longitude of two places to see how far apart they are as the crow flies, in miles, kilometers and nautical miles, and which way to head.

Your numbers

Distance
2,468.6 mi

From 33.95, -118.4 to 40.6333, -73.7833 is 2,468.6 mi as the crow flies.

In kilometers
3,972.9 km
In nautical miles
2,145.2 nmi
Central angle (degrees)
35.7288
Initial bearing (degrees)
65.9

Distance: 2,468.6 mi. From 33.95, -118.4 to 40.6333, -73.7833 is 2,468.6 mi as the crow flies.

How to calculate

Finds the great-circle distance (as the crow flies) between two places from their latitude and longitude, in miles, kilometers, and nautical miles, with the initial compass bearing.

Example with the default inputs (From latitude 33.95, From longitude -118.4, To latitude 40.6333, To longitude -73.7833): From 33.95, -118.4 to 40.6333, -73.7833 is 2,468.6 mi as the crow flies.

Method: a = sin²(Δφ ÷ 2) + cos φ1 × cos φ2 × sin²(Δλ ÷ 2); c = 2 × atan2(√a, √(1 − a)); distance = 6,371.0088 km × c

  • The Earth is a sphere with the mean radius of 6,371.0088 km; the real, slightly flattened Earth differs by under 1%.
  • The distance is along the surface (as the crow flies), not by road.
  • Latitudes are −90 to 90 degrees (north positive) and longitudes −180 to 180 degrees (east positive).

Machine-readable copies: Markdown, JSON.

Worked examples

Each example is checked against the calculator on every build.

  1. From latitude 33.95, From longitude -118.4, To latitude 40.633333, To longitude -73.783333 gives Central angle (degrees) 35.728789, Initial bearing (degrees) 65.892152, Distance 2,468.6 mi.Source: Ed Williams, Aviation Formulary V1.47, worked example LAX to JFK: d = 0.623585 radians, initial course 1.150035 radians (https://edwilliams.org/avform147.htm)
  2. From latitude 0, From longitude 0, To latitude 90, To longitude 0 gives Central angle (degrees) 90, Distance 6,218.4 mi, Initial bearing (degrees) 0.Source: Mean Earth radius 6,371,008.8 m (Moritz, 2000)
  3. From latitude 0, From longitude 0, To latitude 0, To longitude 1 gives Central angle (degrees) 1, In kilometers 111.2 km, Initial bearing (degrees) 90.
  4. From latitude 40, From longitude 179.5, To latitude 40, To longitude -179.5 gives Distance 52.9 mi, Initial bearing (degrees) 89.678601.

How it works

Each place is a latitude φ from −90 to 90 degrees (north positive) and a longitude λ from −180 to 180 degrees (east positive), in decimal degrees. The Earth is a sphere with radius R = 6,371.0088 km, the mean radius of the GRS 80 and WGS 84 ellipsoids.

  1. Longitude difference Δλ = λ2 − λ1, brought into the range −180 to 180 degrees (add 540, take the remainder after dividing by 360, subtract 180), so a path across the 180° meridian goes the short way.
  2. Haversine: a = sin²((φ2 − φ1) ÷ 2) + cos φ1 × cos φ2 × sin²(Δλ ÷ 2), kept between 0 and 1.
  3. Central angle c = 2 × atan2(√a, √(1 − a)), in radians; the page shows it in degrees (4 decimal places).
  4. Distance = R × c, shown in miles (in US units) or kilometers (in metric), kilometers, and nautical miles, to 1 decimal place. 1 mile = 1.609344 km and 1 nautical mile = 1.852 km.
  5. Initial bearing θ = atan2(sin Δλ × cos φ2, cos φ1 × sin φ2 − sin φ1 × cos φ2 × cos Δλ), in degrees, plus 360 if negative, so 0 ≤ θ < 360 (0 is north, 90 east). It is left out when the first place is a pole (latitude 90 or −90), when the two places are the same (c = 0), or when the second place is exactly opposite the first (φ2 = −φ1 and Δλ = ±180), because then no single direction is the shortest.

Worked examples by hand

LAX to JFK (the Aviation Formulary example). LAX is 33°57′ N, 118°24′ W: φ1 = 33.95, λ1 = −118.4. JFK is 40°38′ N, 73°47′ W: φ2 = 40.6333…, λ2 = −73.7833…. The formula gives c = 0.623585 radians (35.7288°), so the distance is 0.623585 × 6,371.0088 = 3,972.9 km, or 2,468.6 miles and 2,145.2 nautical miles. The initial bearing is 1.150035 radians = 65.9°, a little north of east. (The Aviation Formulary gives 2,144 nm because it takes 1 nautical mile as 1 minute of arc; this page uses the mean radius instead.)

Equator to the North Pole (0, 0 to 90, 0). a = sin²(45°) = 0.5, so c = 2 × atan2(√0.5, √0.5) = 90° = π ÷ 2 radians, and the distance is 6,371.0088 × π ÷ 2 = 10,007.6 km, due north (bearing 0°).

One degree along the equator (0, 0 to 0, 1). c = 1° = π ÷ 180 radians, so the distance is 6,371.0088 × π ÷ 180 = 111.2 km, due east (bearing 90°).

Across the 180° meridian (40, 179.5 to 40, −179.5). Δλ = −359 degrees becomes +1 degree. a = cos² 40° × sin² 0.5° = 0.5868 × 0.0000762 = 0.0000447, so c = 0.7660° and the distance is 85.2 km, not most of the way round the world.

Other questions people ask

How is the distance between two places calculated?

On a sphere, the shortest path between two points follows a great circle. The haversine formula finds the angle between the two places seen from the Earth’s center, and the distance is that angle (in radians) times the Earth’s radius. This page uses the mean radius of 6,371.0088 km.

Is this the driving distance?

No. It is the straight-line distance over the Earth’s surface, as the crow flies or a plane flies. Roads bend around terrain and follow a network, so a driving route is always longer.

Where do I find a place’s latitude and longitude?

Most map apps show them when you press and hold on a place. Use decimal degrees, with a minus sign for south latitudes and west longitudes: Los Angeles airport is about 33.95, −118.4.

How do I turn degrees and minutes into decimal degrees?

Divide the minutes by 60 and add them to the degrees; make it negative for south or west. 33°57′ N is 33 + 57 ÷ 60 = 33.95, and 118°24′ W is −(118 + 24 ÷ 60) = −118.4.

How accurate is the answer?

The Earth is slightly flattened (by about 1 part in 298), so a sphere is off by a fraction of a percent, under 1%, compared with an ellipsoid model such as WGS 84. For trip planning, flight distances and school work that is close enough.

What is the initial bearing?

It is the compass direction, in degrees clockwise from true north, to set off in from the first place. On a great circle the direction changes along the way, so the bearing at the end is different.