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.


geohash-poly, a javascript library. From the web site - Transform a GeoJSON (Multi)Polygon to a list of geohashes that cover it. There are 3 geohash filtering options - inside, extent or intersect.


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.

            bbox_latlon   : list of [lat,lon] points
            accuracy      : length of geohash

            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[0], pt[1], accuracy)

        bbox = shapely.geometry.Polygon(bbox_pts)
        while unchecked:
            this = unchecked.pop()

            if bbox.contains(Point(geohash.decode(this))):

                for gh in geohash.neighbors(this):
                    if (gh not in inside) & (gh not in outside) & (gh not in unchecked):


        return inside

Java ones:https://github.com/xlvecle/geohash-poly
it can be used in java/kotlin/scala


use: pip install python-geohash instead of pip install geohash

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.