Guest User

Untitled

a guest
Oct 17th, 2018
85
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.04 KB | None | 0 0
  1. import geohash
  2.  
  3.  
  4. def bbox_geohashes_shapely(bbox_pts, accuracy=5):
  5.  
  6. import geohash
  7. import shapely
  8. from shapely.geometry import Point
  9. d=set()
  10. unchecked = set()
  11. inside = set()
  12. outside = set()
  13. bbox = shapely.geometry.Polygon(bbox_pts)
  14. bbox=bbox.bounds
  15. print (bbox)
  16. box=zip(bbox[0::2],bbox[1::2])
  17. print (box)
  18. for pt in box:
  19. tst_gh = geohash.encode(pt[0], pt[1], accuracy)
  20. unchecked.add(tst_gh)
  21.  
  22. print (unchecked)
  23. for i in unchecked:
  24. d = geohash.decode(i)
  25. print(d)
  26. hash=geohash.encode(d[0],d[1],8)
  27. print(hash)
  28.  
  29. a=bbox_geohashes_shapely([(51.853692,7.3850065),(52.028091,7.3850065),(52.02935,7.74000),(51.95369,7.74000)],8)
  30.  
  31. (51.853692, 7.3850065, 52.02935, 7.74)
  32. [(51.853692, 7.3850065), (52.02935, 7.74)]
  33. set(['u1jxbpsh', 'u1jqbp9t'])
  34. (51.85366630554199, 7.385044097900391)
  35. u1jqbp9t
Add Comment
Please, Sign In to add comment