Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import geohash
- def bbox_geohashes_shapely(bbox_pts, accuracy=5):
- import geohash
- import shapely
- from shapely.geometry import Point
- d=set()
- unchecked = set()
- inside = set()
- outside = set()
- bbox = shapely.geometry.Polygon(bbox_pts)
- bbox=bbox.bounds
- print (bbox)
- box=zip(bbox[0::2],bbox[1::2])
- print (box)
- for pt in box:
- tst_gh = geohash.encode(pt[0], pt[1], accuracy)
- unchecked.add(tst_gh)
- print (unchecked)
- for i in unchecked:
- d = geohash.decode(i)
- print(d)
- hash=geohash.encode(d[0],d[1],8)
- print(hash)
- a=bbox_geohashes_shapely([(51.853692,7.3850065),(52.028091,7.3850065),(52.02935,7.74000),(51.95369,7.74000)],8)
- (51.853692, 7.3850065, 52.02935, 7.74)
- [(51.853692, 7.3850065), (52.02935, 7.74)]
- set(['u1jxbpsh', 'u1jqbp9t'])
- (51.85366630554199, 7.385044097900391)
- u1jqbp9t
Add Comment
Please, Sign In to add comment