Skip to content

Instantly share code, notes, and snippets.

@lmeulen
Created August 22, 2021 18:53
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save lmeulen/e161536d56842c5fbd91599e51624090 to your computer and use it in GitHub Desktop.
Save lmeulen/e161536d56842c5fbd91599e51624090 to your computer and use it in GitHub Desktop.
gpx_distance_haversine
def dist_haversine(lat1, lon1, lat2, lon2):
radius = 6371.0088
lat = lat2 - lat1
lon = lon2 - lon1
d = sin(lat * 0.5) ** 2 + cos(lat1) * cos(lat2) * sin(lon * 0.5) ** 2
return 2 * radius * asin(sqrt(d)) * 1000
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment