Calculate Distance Between Two Cities: Methods and Formula
- Great-circle distance
- mi
- Result
- City A latitude
- 40.7128 degrees
- You entered
- City A longitude
- -74.006 degrees
- You entered
To calculate the distance between two cities, enter their latitudes and longitudes into the great-circle formula; it estimates the shortest distance over Earth’s surface. This calculator uses a sample pair of city coordinates and returns the distance in kilometers and miles, while the method below explains how to calculate any pair.
Formula
The calculator applies the haversine formula, a standard way to find the great-circle distance between two points when their latitude and longitude are known. A great circle is the shortest path between those points along an ideal spherical Earth.
a = sin²(Δφ/2) + cos(φ₁) × cos(φ₂) × sin²(Δλ/2)
c = 2 × asin(√a)
d = R × c
- φ₁ and φ₂ are the latitudes of the two cities, in degrees.
- λ₁ and λ₂ are their longitudes, in degrees.
- Δφ is φ₂ − φ₁; Δλ is λ₂ − λ₁. The calculator’s sind and cosd functions interpret angles in degrees.
- a and c are intermediate, unitless values; the inverse sine returns an angle in radians.
- R is Earth’s mean radius, taken here as 6,371 km. d is the result in kilometers; multiplying by 0.621371 converts it to miles.
Coordinates can be entered as decimal degrees. North and east are positive; south and west are negative. For example, a longitude of 74.0060° west is entered as −74.0060°.
Worked Example
Using the calculator’s default coordinates for New York City and Los Angeles:
- City A: latitude 40.7128°, longitude −74.0060°.
- City B: latitude 34.0522°, longitude −118.2430°.
- Δφ = 34.0522 − 40.7128 = −6.6606°.
- Δλ = −118.2430 − (−74.0060) = −44.2370°.
- Substituting these values gives a great-circle distance of approximately 3,936 km using the 6,371 km radius.
- Convert to miles: 3,936 × 0.621371 ≈ 2,446 miles.
The outputs, rounded to the nearest whole unit as specified in the calculator block, are 3,936 km and 2,446 mi. Small differences from other calculators can result from a different coordinate selection or Earth-radius model.
How to Find and Enter City Coordinates
Use the latitude and longitude for the specific point you want to measure, such as a city center, airport, or named address. A city is an area, not a single mathematical point, so its measured distance depends on which locations represent the two cities. For a fair comparison, choose consistent reference points, such as each city’s central coordinates.
Coordinates may be shown in degrees, minutes, and seconds, or in decimal degrees. Convert them before entering values if needed: decimal degrees equal degrees + minutes/60 + seconds/3,600, with the sign determined by the compass direction. For instance, 40° 42′ 46″ north is about 40.7128° north. Do not enter a west or south coordinate as positive.
What the Distance Does—and Does Not—Mean
The result is a straight, surface-following distance on a spherical model of Earth, not a straight line through the planet and not a route distance. It is often called “as the crow flies,” though a real aircraft route can be longer because it must account for airspace, weather, departure and arrival procedures, and other operational constraints.
Driving, rail, walking, or cycling distances follow available routes and are usually longer. They depend on the road or path network, crossings, one-way streets, terrain, and the chosen start and finish points. To plan a trip, use a route planner and check the relevant transport mode; the coordinate formula is useful for geographic comparison, not navigation instructions.
Accuracy, Units, and Common Mistakes
- Check coordinate order. Many sources list latitude first and longitude second. Swapping them can produce a completely different answer.
- Keep signs and units consistent. Latitude ranges from −90° to 90° and longitude from −180° to 180°. Do not mix decimal degrees with radians or omit the negative sign for west or south.
- Understand rounding. The calculator displays whole kilometers and miles, so its displayed values are approximate. Extra decimal places do not make the underlying city coordinates or spherical-Earth model more precise.
- Choose the right meaning of distance. A great-circle result is appropriate for broad geographic comparisons; road mileage requires a route calculation.
Earth is not a perfect sphere: it is slightly flattened at the poles, and local terrain also varies. The 6,371 km mean-radius approximation is useful for general distances, but specialized surveying or high-precision geodesy may require an ellipsoidal Earth model and more precise coordinates.
Frequently Asked Questions
How do I calculate the distance between two cities by hand?
Find each city’s latitude and longitude, convert them to radians if using a formula written for radians, then apply the haversine equations and multiply the central angle by Earth’s radius. The calculator handles the angle conversion through degree-based trigonometric functions.
Is the distance between cities the same as driving distance?
No. The great-circle calculation measures the shortest surface path on a spherical Earth. Driving distance follows roads and depends on the route, so it is generally different.
Why do two distance calculators show different results?
They may use different city-center coordinates, reference points, Earth models, or rounding. Check that both calculations compare the same locations and report the same unit.
Can I use this formula for locations other than cities?
Yes. It works for any two points on Earth when their latitude and longitude are known, including towns, landmarks, or coordinates. The result remains a great-circle estimate rather than a travel route.
How do I convert kilometers to miles?
Multiply kilometers by 0.621371 to get miles. To convert miles to kilometers, multiply by 1.60934. These are unit conversions, not changes to the measured route.
Related
Formula used
in lat1 | City A latitude | degrees | 40.7128 | -90 in lon1 | City A longitude | degrees | -74.0060 in lat2 | City B latitude | degrees | 34.0522 in lon2 | City B longitude | degrees | -90 out km | Great-circle distance | km | 6371 * 2 * asin(sqrt(sind((lat2 - lat1) / 2)^2 + cosd(lat1) * cosd(lat2) * sind((lon2 - lon1) / 2)^2)) | 0 out mi | Great-circle distance | mi | km * 0.621371 | 0
Each line is one input (in, sel, list) or one result (out: label, unit, formula, decimals). How the calculators work
Method: the standard formula for this calculation, rounded as each result states. See how the calculators work or report an error.