Skip to content

Instantly share code, notes, and snippets.

@invisiblefunnel
Created March 5, 2020 03:13
Show Gist options
  • Save invisiblefunnel/41796a5e38b13ba324c739f4cc7f9762 to your computer and use it in GitHub Desktop.
Save invisiblefunnel/41796a5e38b13ba324c739f4cc7f9762 to your computer and use it in GitHub Desktop.
import utm
from shapely.geometry import Point
def bbox_from_point(point, meters):
easting, northing, zn, zl = utm.from_latlon(point.y, point.x)
point = Point(easting, northing)
bounds = point.buffer(meters).bounds
minx, miny, maxx, maxy = bounds
result = []
for e, n in ((minx, miny), (maxx, maxy)):
lat, lon = utm.to_latlon(e, n, zn, zl)
result.append(lon)
result.append(lat)
return tuple(result)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment