What this calculator does
This tool finds the shortest path between two points on Earth's surface and the direction you must initially head to follow it. Given the latitude and longitude of City A and City B, it returns the great-circle distance in kilometers, miles, and nautical miles, plus the initial azimuth (forward bearing) measured clockwise from true North and a verbal compass label such as NNE or SW.
How to use it
Enter the decimal-degree coordinates of each location. Latitudes range from -90 (South) to 90 (North); longitudes range from -180 (West) to 180 (East). Click calculate to see the distance and bearing. The defaults are Tokyo (City A) and New York (City B).
The formula explained
The distance uses the numerically stable haversine form. With phi as latitude in radians and lambda as longitude in radians, it computes \(a = \sin^{2}\frac{\Delta\varphi}{2} + \cos\varphi_1\cdot\cos\varphi_2\cdot\sin^{2}\frac{\Delta\lambda}{2}\), then the central angle \(c = 2\cdot\operatorname{atan2}(\sqrt{a},\,\sqrt{1-a})\). Multiplying by the mean Earth radius \(R = 6371\ \text{km}\) gives the distance. The azimuth uses atan2 of the cross-track and along-track components so the bearing lands in the correct quadrant, then is normalized to the range [0, 360).
$$\begin{gathered} d = 2R\,\arctan\!\left(\frac{\sqrt{a}}{\sqrt{1-a}}\right), \qquad \theta = \operatorname{atan2}(y,\,x) \\[1.5em] \text{where}\quad \left\{ \begin{aligned} a &= \sin^{2}\!\frac{\Delta\varphi}{2} + \cos\varphi_1\cos\varphi_2\,\sin^{2}\!\frac{\Delta\lambda}{2} \\ y &= \sin\Delta\lambda\,\cos\varphi_2 \\ x &= \cos\varphi_1\sin\varphi_2 - \sin\varphi_1\cos\varphi_2\cos\Delta\lambda \\ \varphi_1 &= \text{Lat}_A\cdot\tfrac{\pi}{180}, \quad \varphi_2 = \text{Lat}_B\cdot\tfrac{\pi}{180} \\ \Delta\varphi &= \varphi_2-\varphi_1, \quad \Delta\lambda = \left(\text{Lon}_B-\text{Lon}_A\right)\tfrac{\pi}{180} \\ R &= 6371\ \text{km} \end{aligned} \right. \end{gathered}$$
Worked example: Tokyo to New York
For Tokyo (35.6895, 139.6917) and New York (40.7128, -74.0060), the haversine central angle is about \(1.7027\) radians, giving roughly \(10{,}849\ \text{km}\), about \(6{,}741\) miles and \(5{,}858\) nautical miles. The initial bearing is about \(25.1\) degrees, a north-northeast (NNE) heading along the great circle.
FAQ
Why does the bearing change along the route? A great-circle path is the shortest route but not a constant compass heading; the reported azimuth is only the initial bearing at the start.
How accurate is it? It uses a spherical Earth (\(R = 6371\ \text{km}\)). An ellipsoidal model like Vincenty/WGS-84 is about 0.5% more precise but more complex.
What if both points are identical? Distance is 0 and the azimuth is undefined; the calculator returns 0 degrees.