pythonpandasgeolocationdata-sciencegeocode

How to decode geohash using python in pandas?


I need code to decode geohash in python. There's a column which contains geohashes. I need them decoded into latitude and longitude.


Solution

  • You can install pygeohash from pypi using pip

    $ pip install pygeohash
    

    Then add a new column to the dataframe with the latitude and longitude

    import pygeohash as pgh
    # ...
    # location is a new column filled with (lat, lon) tuples
    df['location'] = df.apply(lambda rec: pgh.decode(rec['geohash']), axis=1)
    

    Here 'geohash' is the column which contains geohashes.