Skip to content

Instantly share code, notes, and snippets.

@jliu90
Last active August 29, 2015 14:03
Show Gist options
  • Save jliu90/ceec153585ee27ef49ca to your computer and use it in GitHub Desktop.
Save jliu90/ceec153585ee27ef49ca to your computer and use it in GitHub Desktop.
#helper function to estimate long/lat range based on long/lat and range in km
def calc_longlat_range(longitude, latitude, range_km):
from math import cos, radians, pi
r = 6370
alpha = radians(latitude)
circum = 2 * pi * cos(alpha) * r
km_per_long = circum / 360
km_per_lat = pi * r / 180
result = dict()
result["lat_range"] = range_km / km_per_lat
result["long_range"] = range_km / km_per_long
return result
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment