GPS Distance & Bearing Calculator (Haversine & Vincenty)

Calculate the great-circle distance, initial and final bearing and midpoint between two latitude/longitude points, with haversine and the more accurate Vincenty ellipsoid formula.

Updated · Free · Runs in your browser

Decimal (40.7128) or DMS (40° 42′ 46″ N). South is negative.

West is negative.

Great-circle distance —
Ellipsoidal distance (Vincenty) —
Initial bearing —
Final bearing —
Midpoint —
Flight time estimate —
    Was this calculator helpful?

    The formula

    Haversine: a = sin²(Δφ/2) + cos φ₁ × cos φ₂ × sin²(Δλ/2)
    Distance d = 2R × atan2(√a, √(1 − a)), with mean Earth radius R = 6,371.0 km
    Initial bearing θ = atan2(sin Δλ × cos φ₂, cos φ₁ × sin φ₂ − sin φ₁ × cos φ₂ × cos Δλ)
    Vincenty's formula iterates on the WGS-84 ellipsoid (a = 6,378,137 m, f = 1/298.257)
    DMS to decimal: degrees + minutes/60 + seconds/3,600

    Worked example

    1. New York (40.7128, −74.0060) to London (51.5074, −0.1278):
    2. Haversine distance = 5,570 km (3,461 miles, 3,008 nautical miles).
    3. The Vincenty ellipsoidal distance is about 5,585 km.
    4. Initial bearing 51.2° (northeast); final bearing about 108° on arrival, because the great circle curves.

    Distance on a sphere

    The shortest path between two points on the Earth's surface is an arc of a great circle, a circle whose centre is the centre of the Earth. The haversine formula calculates this great-circle distance from the latitudes and longitudes of two points, treating the Earth as a sphere with a mean radius of 6,371 km. It's numerically stable for both short and long distances, which made it popular for navigation before computers, and it's still the standard choice in apps and databases where accuracy within about 0.5% is enough.

    Vincenty: allowing for the Earth's shape

    The Earth isn't a perfect sphere: it bulges at the equator, so its equatorial radius is about 21 km larger than its polar radius. Vincenty's formulae calculate distance on the WGS-84 ellipsoid used by GPS and are accurate to within millimetres. The difference from haversine is usually small, up to about 0.5%, but it matters for surveying, aviation and long-range navigation. The calculator shows both. For nearly antipodal points, on opposite sides of the Earth, Vincenty's method can fail to converge, and the haversine result is then the one to use.

    Bearings

    The initial bearing is the compass direction you'd set off in from the first point to follow the great circle, measured clockwise from true north. On a long great-circle route, the bearing changes continuously, so the final bearing on arrival is usually different. That's why flights from New York to London head northeast and curve over the Atlantic. Pilots and sailors following a constant compass heading travel along a rhumb line instead, which is longer except along the equator or a meridian. Bearings here are true, not magnetic; add or subtract your local magnetic declination for a compass.

    Entering coordinates

    You can type coordinates in decimal degrees, such as 51.5074 and −0.1278, or in degrees, minutes and seconds, such as 51° 30′ 26″ N and 0° 7′ 40″ W. North latitudes and east longitudes are positive; south and west are negative, or you can add the letters S and W. Most maps and phones can show coordinates for any point: in Google Maps, for example, right-click or long-press on a location. One degree of latitude is about 111 km, and the fifth decimal place of a decimal degree is about 1 m.

    Uses of GPS distance

    Great-circle distances are used to estimate flight distances and fuel, calculate shipping routes, find the nearest store or branch in location-based apps, analyse fitness tracker data, geocache and check how far away a thunderstorm or earthquake is. For road trips, actual driving distance is longer because roads aren't straight; our road trip calculator plans fuel and stops. For time differences between two places, use the time zone converter.

    Flat-map distances

    For short distances on a local map, such as across a town, the Earth's curvature hardly matters and you can treat coordinates as a flat grid, but longitude degrees shrink towards the poles, by a factor of cos(latitude). For planar coordinates on a graph, use our distance and midpoint calculator. To convert a distance measured on a paper map, use the map scale calculator. For sun times at a location, try the sunrise and sunset calculator.

    Frequently asked questions

    How do I calculate the distance between two GPS coordinates?
    Use the haversine formula with the two latitudes and longitudes in radians and the Earth's radius. This calculator does it for you and also gives the more precise Vincenty ellipsoidal distance.
    How accurate is the haversine formula?
    Typically within 0.3–0.5% of the true distance, because it treats the Earth as a sphere. Vincenty's method on the WGS-84 ellipsoid is accurate to within millimetres.
    What is the difference between initial and final bearing?
    On a great-circle route the direction changes as you travel. The initial bearing is your starting direction and the final bearing is your direction on arrival.
    How do I convert degrees, minutes and seconds to decimal?
    Add degrees + minutes ÷ 60 + seconds ÷ 3,600, and make the result negative for south or west. 40° 42′ 46″ N is 40.7128.
    Why is the flight distance shorter than it looks on a map?
    Flat maps such as the Mercator projection distort distances, especially at high latitudes. A great-circle route that looks curved on the map is actually the shortest path.

    ↑↓ to navigate · Enter to open