Distance Calculator
- Updated
- Formula shown
- Free, no sign-up
Results
Distance between (1, 2) and (4, 6) is 5
How to use the distance calculator
- Choose 2D points, 3D points or latitude / longitude.
- For points, enter the coordinates of both ends. Negative values are fine.
- For places, enter decimal degrees: north and east positive, south and west negative (so 74.006° W is −74.006). Map apps show these when you press on a location.
- Read the distance, plus the differences, midpoint and direction, or the bearings for a route on the globe.
Distance formulas
3D: d = √((x₂ − x₁)² + (y₂ − y₁)² + (z₂ − z₁)²)
Haversine: a = sin²(Δφ ÷ 2) + cos φ₁ · cos φ₂ · sin²(Δλ ÷ 2), d = 2R · atan2(√a, √(1 − a))
Initial bearing: θ = atan2(sin Δλ · cos φ₂, cos φ₁ · sin φ₂ − sin φ₁ · cos φ₂ · cos Δλ)
The 2D formula is the Pythagorean theorem: the horizontal and vertical differences are the legs of a right triangle and the distance is its hypotenuse. Adding a third difference gives the 3D version. On a globe, straight lines are replaced by great circles, the shortest route over the surface. In the haversine formula, φ is latitude, λ is longitude (both in radians), Δ means the difference between the two places, and R is the Earth's radius. This calculator uses the IUGG mean radius, 6,371.0088 km. The haversine form stays accurate even for points very close together, where the older spherical law of cosines loses precision.
Worked examples
- 2D: from (1, 2) to (4, 6), the differences are 3 and 4, so d = √(9 + 16) = 5.
- 3D: from (1, 2, 3) to (4, 6, 15), d = √(3² + 4² + 12²) = √169 = 13.
- On the globe: from New York (40.7128° N, 74.0060° W) to London (51.5074° N, 0.1278° W), the great-circle distance is about 5,570 km (3,461 miles). The route leaves New York on a bearing of 51.2° (NE) and arrives heading 108.3°: the direction changes along a great circle, which is why the shortest route looks curved on a flat map.
Great-circle distances between cities
Computed with the calculator's haversine engine from approximate city-center coordinates. Actual flight distances are a little longer.
| From | To | Kilometers | Miles | Initial bearing |
|---|---|---|---|---|
| London | Paris | 344 | 213 | 148.1° (SSE) |
| New York | Los Angeles | 3,936 | 2,446 | 273.7° (W) |
| New York | London | 5,570 | 3,461 | 51.2° (NE) |
| Tokyo | Sydney | 7,826 | 4,863 | 169.8° (S) |
| Los Angeles | Tokyo | 8,819 | 5,480 | 306.1° (NW) |
| London | Sydney | 16,994 | 10,560 | 60.7° (ENE) |
How long is a degree?
On the spherical model, one degree of latitude is always about 111.2 km (69.09 miles). A degree of longitude shrinks towards the poles, in proportion to the cosine of the latitude:
| Latitude | 1° of longitude (km) | 1° of longitude (miles) |
|---|---|---|
| 0° | 111.2 | 69.09 |
| 15° | 107.41 | 66.74 |
| 30° | 96.3 | 59.84 |
| 45° | 78.63 | 48.86 |
| 60° | 55.6 | 34.55 |
| 75° | 28.78 | 17.88 |
Tips and limitations
- Check the signs. Forgetting the minus on a western longitude or southern latitude puts the point in the wrong hemisphere, often thousands of kilometers away.
- Degrees, minutes and seconds: convert to decimals first: 40° 42′ 46″ = 40 + 42 ÷ 60 + 46 ÷ 3600 = 40.7128°.
- Accuracy: treating the Earth as a sphere is within about 0.5% of the true ellipsoidal distance, which is fine for planning but not for surveying.
- Bearings are true, not magnetic. A compass points to magnetic north, which differs from true north by the local magnetic declination.
The slope, rise and run between the same two points are in the slope calculator, and the Pythagorean theorem calculator shows the a² + b² = c² working behind the 2D distance.
Frequently asked questions
How do I find the distance between two points?
Subtract the x-coordinates and the y-coordinates, square both differences, add them and take the square root: d = √((x₂ − x₁)² + (y₂ − y₁)²). From (1, 2) to (4, 6) the distance is √(9 + 16) = 5.
How do I find the distance between two points in 3D?
Add the square of the z difference too: d = √(Δx² + Δy² + Δz²). From (1, 2, 3) to (4, 6, 15), the differences are 3, 4 and 12, so the distance is √169 = 13.
What is the haversine formula?
It gives the great-circle distance between two latitude/longitude points on a sphere, and stays accurate even for nearby points. With the mean Earth radius of 6,371.0088 km, New York to London comes out at about 5,570 km (3,461 miles).
What is the initial bearing?
The compass direction, measured clockwise from true north, in which you set off along the great circle. From New York to London it is about 51° (north-east), but the heading changes along the way and is about 108° on arrival.
Why does the shortest route look curved on a map?
Flat maps stretch the globe, so a great circle, the shortest path over a sphere, usually appears as a curve bending towards the nearer pole. That is why many flights between Europe and North America pass over or near Greenland.