Astronomy Site Header Image
Home Learn Blog About me
Haversine Distance Calculator

Calculate distance between two points on a Earth

Distance (km):

Haversine Distance Calculation

The Haversine formula is used to calculate the distance between two points on the surface of a sphere, such as the Earth. It takes into account the latitude and longitude of both points and calculates the shortest distance between them, often referred to as the "as-the-crow-flies" distance.

The formula is given by:

        a = sin²(Δlat/2) + cos(lat1) * cos(lat2) * sin²(Δlon/2)
        c = 2 * atan2(√a, √(1-a))
        distance = R * c
        

Where:

  • Δlat is the difference in latitude between the two points.
  • Δlon is the difference in longitude between the two points.
  • lat1 and lat2 are the latitudes of the two points in radians.
  • R is the radius of the Earth (mean radius = 6,371 km).
  • c is the distance between the two points along the surface of the sphere.