# Distance between two places

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.

- Page: https://www.acalculator.org/everyday-life/distance-calculator
- JSON spec: https://www.acalculator.org/everyday-life/distance-calculator.json
- Version: 2684ad347949

## Default answer

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.

## Inputs

| Key | Label | Description |
| --- | --- | --- |
| lat1 | From latitude | Latitude of the first place in decimal degrees; north is positive. |
| lon1 | From longitude | Longitude of the first place in decimal degrees; east is positive, west negative. |
| lat2 | To latitude | Latitude of the second place in decimal degrees; north is positive. |
| lon2 | To longitude | Longitude of the second place in decimal degrees; east is positive, west negative. |

## Outputs

| Key | Label | Description |
| --- | --- | --- |
| distance | Distance | The great-circle distance: the shortest path along the Earth’s surface, on a sphere. |
| km | In kilometers | The same distance in kilometers. |
| nmi | In nautical miles | The same distance in nautical miles (1,852 m). |
| angle | Central angle (degrees) | The angle between the two places seen from the Earth’s center, in degrees. |
| bearing | Initial bearing (degrees) | The compass direction to set off in from the first place, in degrees clockwise from true north (0 to 360). |

## Method

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

## Assumptions

- 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).

## Worked examples

1. lat1 = 33.95, lon1 = -118.4, lat2 = 40.633333, lon2 = -73.783333 gives angle = 35.728789, bearing = 65.892152, distance = 3,972,865.522548. 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. lat1 = 0, lon1 = 0, lat2 = 90, lon2 = 0 gives angle = 90, distance = 10,007,557.221018, bearing = 0. Source: Mean Earth radius 6,371,008.8 m (Moritz, 2000).
3. lat1 = 0, lon1 = 0, lat2 = 0, lon2 = 1 gives angle = 1, km = 111,195.080234, bearing = 90.
4. lat1 = 40, lon1 = 179.5, lat2 = 40, lon2 = -179.5 gives distance = 85,179.926606, bearing = 89.678601.

## FAQ

### 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.

## Sources

- Ed Williams, Aviation Formulary V1.47: the haversine distance and the initial course between two points, with the LAX to JFK example. https://edwilliams.org/avform147.htm
- H. Moritz, Geodetic Reference System 1980, Journal of Geodesy 74 (2000), 128–133: the mean Earth radius R1 = 6,371,008.8 m.
- NIST SP 811 (2008), Appendix B: 1 mi = 1.609344 km and 1 nautical mile = 1,852 m exactly.
