Given latitude and longitude and distance, I want to find a bounding box where the distances are less than a given distance.
The following questions were asked here: How to calculate the bounding box for a given lat / lng location?
I want this to be partially accurate, so I changed and simplified it to
def boundingBox(latitudeInDegrees, longitudeInDegrees, halfSideInKm):
lat = math.radians(latitudeInDegrees)
lon = math.radians(longitudeInDegrees)
halfSide = 1000*halfSideInKm
RADIUS_OF_EARTH = 6371
pradius = radius*math.cos(lat)
latMin = lat - halfSide/radius
latMax = lat + halfSide/radius
lonMin = lon - halfSide/pradius
lonMax = lon + halfSide/pradius
rad2deg = math.degrees
return (rad2deg(latMin), rad2deg(lonMin), rad2deg(latMax), rad2deg(lonMax))
But I can’t understand how it works, in particular, this line does not make any sense to me halfSide = 1000*halfSideInKm
source
share