Haversine Formula
The Haversine formula calculates the great-circle distance between two points on a sphere given their latitude and longitude coordinates. It is the standard method for computing geographic distances in mapping applications, navigation systems, and location-based services.
The Haversine formula is a trigonometric equation used to calculate the shortest distance between two points on the surface of a sphere along the surface itself (the great-circle distance). It uses the latitude and longitude of both points, applying the haversine function (half the versed sine) to account for the curvature of the Earth.
Mathematical Foundation
The formula computes the central angle between two points using: hav(d/R) = hav(lat2 - lat1) + cos(lat1) * cos(lat2) * hav(lon2 - lon1), where d is the distance, R is the Earth's radius, and hav is the haversine function defined as hav(theta) = sin^2(theta/2). The great-circle distance is then d = 2R * arcsin(sqrt(a)), where a is the haversine value. The Earth's mean radius (approximately 6,371 km) is used for general calculations, though ellipsoidal corrections improve accuracy for precise geodetic work.
Applications
Location-based servicesLocation-Based ServicesLocation-based services (LBS) are applications and platforms that use geographic location data from mobile devices to... and mapping applications use the Haversine formula to compute distances between GPSGPSThe Global Positioning System (GPS) is a satellite-based navigation system operated by the U.S. Space Force that prov... coordinates for routing, proximity searches, and geofencingGeofencingGeofencing creates virtual boundaries around real-world geographic areas, triggering automated actions when mobile de.... Database systems implement it for spatial queries such as finding all points of interestPoints of InterestPoints of interest (POI) are specific geographic locations that are useful or notable for a particular purpose—such a... within a given radius. Logistics companies calculate shipping distances between global locations. Aviation uses great-circle distances for flight path planning. The formula is implemented in virtually every GISGISGeographic Information Systems (GIS) enable users to analyze and visualize spatial data to uncover patterns, relation... library, including PostGISPostGISPostGIS is an open-source extension for PostgreSQL databases that introduces support for geographic objects, allowing..., Turf.jsTurf.jsTurf.js is an open-source JavaScript library for advanced geospatial analysis in the browser and on Node.js. It provi..., and GeoPandasGeoPandasGeoPandas is a Python library that extends pandas DataFrames with geospatial capabilities. It enables spatial operati....
Accuracy Considerations
The Haversine formula assumes a perfectly spherical Earth, introducing errors of up to about 0.3 percent compared to the true ellipsoidal shape. For applications requiring higher accuracy, Vincenty's formulae or Karney's algorithm account for the Earth's oblate spheroid geometry. For short distances (under a few kilometers), the simpler equirectangular approximation may suffice with negligible error.
Bereit?
Sehen Sie Mapular
in Aktion.
Buchen Sie eine kostenlose 30-minütige Demo. Wir zeigen Ihnen genau, wie die Plattform für Ihren Anwendungsfall funktioniert — kein generisches Foliendeck, keine Verpflichtung.