-
-
Save erickgnavar/4350691 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def haversine(site_one, site_2): | |
""" | |
Calculate the great circle distance between two points | |
on the earth (specified in decimal degrees) | |
""" | |
lat1 , lon1 = site_one | |
lat2 , lon2 = site_2 | |
# convert decimal degrees to radians | |
lon1, lat1, lon2, lat2 = map(radians, [lon1, lat1, lon2, lat2]) | |
distance = acos(sin(lat1)*sin(lat2)+cos(lat1)*cos(lat2)*cos(lon2-lon1))*6371 | |
distance = distance * 1000 | |
return distance | |
google = 37.422045, -122.084347 | |
tower = 48.8582, 2.294407 | |
opera = -33.856553, 151.214696 | |
sf = 37.77493, -122.419416 | |
print haversine(google,tower) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment