Distance Calculator: Formula to Calculate Distance Using Longitude and Latitude


Longitude and Latitude Distance Calculator

Use the form below to apply the formula to calculate distance using longitude and latitude coordinates for any two points on Earth.



In decimal degrees (-90 to 90)


In decimal degrees (-180 to 180)


In decimal degrees (-90 to 90)


In decimal degrees (-180 to 180)



Chart comparing the calculated distance in different units.

What is the Formula to Calculate Distance Using Longitude and Latitude?

The primary method to calculate the distance between two points from their longitude and latitude is the Haversine formula. This formula calculates the great-circle distance between two points on a sphere, which is the shortest distance over the Earth’s surface. It’s widely used in navigation and geodesy because it accounts for the planet’s curvature. Anyone from pilots and sailors to data scientists and app developers might use this formula. A common misunderstanding is thinking a straight line on a flat map is the shortest distance, but on a spherical Earth, the shortest path is an arc of a great circle.

The Haversine Formula and Explanation

The Haversine formula is a specific application of spherical trigonometry. It’s preferred over other methods like the spherical law of cosines for small distances because it’s less prone to rounding errors. The formula to calculate distance using longitude and latitude involves several steps:

Formula:

a = sin²(Δφ/2) + cos(φ₁) * cos(φ₂) * sin²(Δλ/2)

c = 2 * atan2(√a, √(1−a))

d = R * c

This may look complex, but our calculator handles all the math for you. Simply input your coordinates to see the formula to calculate distance using longitude and latitude in action. For more on spherical geometry, see our guide on Understanding Great Circles.

Variables in the Haversine Formula
Variable Meaning Unit (Auto-Inferred) Typical Range
φ₁, φ₂ Latitude of point 1 and point 2 Radians (converted from degrees) -π/2 to +π/2 (-90° to +90°)
λ₁, λ₂ Longitude of point 1 and point 2 Radians (converted from degrees) -π to +π (-180° to +180°)
Δφ, Δλ Difference in latitude and longitude Radians Varies
R Earth’s mean radius Kilometers or Miles ~6,371 km or ~3,959 mi
d The final distance Kilometers or Miles 0 to ~20,000 km

Practical Examples

Example 1: New York to London

  • Inputs:
    • Point 1 (New York): Latitude 40.7128°, Longitude -74.0060°
    • Point 2 (London): Latitude 51.5074°, Longitude -0.1278°
    • Unit: Kilometers
  • Result: Approximately 5,570 km

Example 2: Sydney to Los Angeles

  • Inputs:
    • Point 1 (Sydney): Latitude -33.8688°, Longitude 151.2093°
    • Point 2 (Los Angeles): Latitude 34.0522°, Longitude -118.2437°
    • Unit: Miles
  • Result: Approximately 7,500 miles

Need to convert coordinates first? Try our Coordinate Conversion Tool.

How to Use This Longitude and Latitude Distance Calculator

  1. Enter Point 1 Coordinates: Input the latitude and longitude for your starting point in the first two fields. Use negative values for South latitudes and West longitudes.
  2. Enter Point 2 Coordinates: Input the latitude and longitude for your destination in the second two fields.
  3. Select Units: Choose whether you want the result in kilometers or miles from the dropdown menu.
  4. Calculate: Click the “Calculate Distance” button. The calculator will apply the formula to calculate distance using longitude and latitude and instantly display the result.
  5. Interpret Results: The main result is the great-circle distance. The breakdown shows intermediate values from the formula, and the chart provides a visual comparison.

Key Factors That Affect Distance Calculation

  • Earth’s Shape: The Haversine formula assumes a perfect sphere. In reality, the Earth is an oblate spheroid (slightly flattened at the poles), which can cause minor inaccuracies (up to 0.5%).
  • Choice of Earth’s Radius: The mean radius (about 6,371 km) is a good average, but using the equatorial or polar radius would give slightly different results.
  • Altitude: This formula calculates distance at sea level. It does not account for differences in elevation between points.
  • Coordinate Precision: The more decimal places you use in your latitude and longitude, the more accurate the distance calculation will be.
  • Path Taken: The result is the shortest possible distance (an “as-the-crow-flies” path), not the actual travel or driving distance, which would be longer. Check out our Driving Distance Calculator for road travel.
  • Unit System: Whether you use kilometers or miles will change the final number, but not the actual distance. Our calculator handles the conversion automatically.

Frequently Asked Questions (FAQ)

1. What is a great-circle distance?

A great-circle distance is the shortest path between two points on the surface of a sphere. It follows the curve of the Earth, unlike a straight line on a flat map.

2. Why not just use the Pythagorean theorem?

The Pythagorean theorem works for flat surfaces (Euclidean geometry), not curved ones. Using it with latitude and longitude would produce significant errors, especially over long distances. Find out more about geodetic formulas here.

3. How accurate is the Haversine formula?

It’s very accurate for a spherical model, typically within 0.5% of the true distance. The main source of error is the Earth’s non-spherical shape.

4. Why is the result different from Google Maps?

Google Maps and other advanced systems use more complex models like the Vincenty’s formulae, which are based on an ellipsoidal Earth model. They also calculate routing distances for roads, not direct paths.

5. What do negative latitude and longitude mean?

Negative latitude values represent the Southern Hemisphere, and negative longitude values represent the Western Hemisphere. For example, Sydney is at approximately -34° latitude, and New York is at -74° longitude.

6. What units should I use for input?

You must use decimal degrees for the latitude and longitude inputs. If your coordinates are in Degrees/Minutes/Seconds (DMS), you’ll need to convert them first with a DMS to Decimal Converter.

7. Can this calculator handle crossing the antimeridian (180° longitude)?

Yes, the mathematical logic correctly handles calculations that cross the antimeridian or the equator.

8. What is the maximum possible distance this calculator can show?

The maximum great-circle distance is approximately half of the Earth’s circumference, about 20,000 km or 12,450 miles, which is the distance to an antipodal point (the direct opposite point on the globe).

Related Tools and Internal Resources

Explore other tools and articles that build on the formula to calculate distance using longitude and latitude:

© 2026 GeoCalculators Inc. All rights reserved.



Leave a Reply

Your email address will not be published. Required fields are marked *