There are plenty of Python libraries that convert Point to geohash. I need to convert an area, enclosed in Polygon to do that. I can't just go around the perimeter points, I'll have a hole inside.
Googling did not reveal any such functionality.
Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. It only takes a minute to sign up.Sign up to join this community
I realize this is an old question, but I hope this function helps future users.
def bbox_geohashes_shapely(bbox_pts, accuracy=5): """ Given a list of lat/lon points marking the bounding box, return all geohashes within the box. Bounding box can be an arbitrary simple polygon (i.e., any number of sides are okay, but inclusions are not). To see geohashes overlaid on map, visit http://geohash.gofreerange.com/ All bounding points are checked for in/out. After converting bounding points to geohashes, all neighbors are checked for presence in/out of bounding box. Neighbors of those points still inside are also checked, until no more points remain. Parameters: ----------- bbox_latlon : list of [lat,lon] points accuracy : length of geohash Returns: -------- inside : set of hashes contained within bounding box """ import geohash import shapely from shapely.geometry import Point unchecked = set() inside = set() outside = set() for pt in bbox_pts: tst_gh = geohash.encode(pt, pt, accuracy) unchecked.add(tst_gh) bbox = shapely.geometry.Polygon(bbox_pts) while unchecked: this = unchecked.pop() if bbox.contains(Point(geohash.decode(this))): inside.add(this) for gh in geohash.neighbors(this): if (gh not in inside) & (gh not in outside) & (gh not in unchecked): unchecked.add(gh) else: outside.add(this) return inside
it can be used in java/kotlin/scala