Geographic Distance Calculator
Calculate great-circle distance between two locations using the Haversine formula.
关于此工具
The Geographic Distance Calculator computes the shortest surface distance between any two points on Earth. Enter latitude/longitude coordinates manually or type a city or place name to look up coordinates via the free Nominatim geocoding API (no API key needed). Results include the great-circle distance in kilometres, miles, and nautical miles, plus initial and final bearing and the midpoint coordinates. A simple SVG globe illustrates the two points and the arc between them.
使用方法
- 1 Enter coordinates or a place name for Location A.
- 2 Enter coordinates or a place name for Location B.
- 3 Click 'Calculate Distance'.
- 4 Read the distance in km, miles, and nautical miles.
- 5 See initial bearing, final bearing, and midpoint in the results panel.
Why straight-line distance needs a special formula
The Earth is very nearly a sphere, so the shortest path between two points on its surface is not a straight line through the ground but an arc that follows the curve — a great circle. You cannot find that arc by treating latitude and longitude like flat grid coordinates, because a degree of longitude shrinks as you move away from the equator toward the poles. This calculator uses the Haversine formula, which is built for exactly this problem: given two points' latitudes and longitudes, it returns the great-circle distance across the surface of a sphere.
The tool models the Earth with a single mean radius of 6,371 km. That is a deliberate simplification — the planet is slightly flattened at the poles — but for ordinary use the error is well under a percent, far smaller than the difference between this "as the crow flies" figure and any real driving route.
How the Haversine formula works
The formula computes the angle subtended at the Earth's centre between your two points, then multiplies that angle (in radians) by the radius to get arc length. In the form this tool uses:
- Take the differences in latitude (
Δlat) and longitude (Δlon), converted to radians. - Compute
a = sin²(Δlat/2) + cos(lat₁) · cos(lat₂) · sin²(Δlon/2). - Compute the central angle
c = 2 · atan2(√a, √(1−a)). - Distance
= 6371 · ckilometres.
The kilometre result is then converted to miles (× 0.621371) and nautical miles (× 0.539957). A nautical mile is itself defined as one minute of arc along a meridian, which is why sailors and pilots prefer it.
A worked example: London to New York
Take London (51.5074°N, 0.1278°W) and New York (40.7128°N, 74.0060°W). Feeding these into the formula gives a central angle of roughly 0.876 radians, so the distance is about 6371 × 0.876 ≈ 5,570 km — close to 5,570 km, 3,461 miles, 3,008 nautical miles. The tool also reports the initial bearing of about 288° (just north of due west, WNW) and a quite different final bearing. On a long east–west route the compass heading rotates as you travel, which is why the two bearings disagree and why great-circle flight paths curve north on a flat map.
Bearings and the midpoint
The initial bearing is the compass direction you would set off in, measured clockwise from north (0° = N, 90° = E, 180° = S, 270° = W). The final bearing is the direction you are travelling when you arrive. The tool also computes the geographic midpoint — the point that lies on the great-circle arc exactly halfway between A and B. Note this is not the simple average of the two coordinates; averaging latitudes and longitudes gives the wrong answer for points far apart or near the poles, so the calculator uses proper spherical geometry. A small SVG world map plots both points and the connecting arc so you can sanity-check the result at a glance.
Looking up coordinates by name
You do not need to know coordinates by heart. Type a city or place name and click Look up, and the tool queries the free Nominatim geocoding service from OpenStreetMap to resolve the name into latitude and longitude — no account or API key needed. This is the one part of the tool that contacts an external server: the place name you type is sent to Nominatim to fetch coordinates. The distance maths itself runs entirely in your browser. If you would rather not send anything externally, paste coordinates directly into the latitude and longitude fields instead.
Common use cases and tips
- Flight planning and travel estimates. Great-circle distance is the basis for airline mileage and rough flight-time estimates.
- "How far apart are we?" Quickly settle the distance between two cities, landmarks, or a pair of GPS coordinates from a photo or device.
- Sailing and aviation. The nautical-mile output and bearings map directly onto navigation charts.
- Geofencing and proximity logic. Developers use Haversine to check whether two points fall within a radius.
One caution: this is straight-line distance, not road distance. A drive from London to Edinburgh covers more kilometres than the great circle because roads bend around terrain. If your result looks shorter than a mapping app's driving figure, that is expected — the two are measuring different things. Also remember the sign convention: west longitudes and south latitudes are negative, so New York's longitude is −74.006, not 74.006.