{"id":3779,"library":"python-geohash","title":"Python Geohash (Legacy)","description":"This is a legacy version (0.8.5) of a Python library for fast and accurate geohashing, providing functions to encode and decode geohashes to and from latitude/longitude coordinates. It originated from a Google Code project and was last updated in 2014. For actively maintained geohashing functionality, consider the 'pygeohash' library.","status":"abandoned","version":"0.8.5","language":"en","source_language":"en","source_url":"https://github.com/hkwi/python-geohash","tags":["geohash","gis","location","encoding","decoding","spatial"],"install":[{"cmd":"pip install python-geohash","lang":"bash","label":"Basic installation"}],"dependencies":[],"imports":[{"note":"The package name for installation is 'python-geohash', but the import module name is 'geohash'.","wrong":"import python_geohash as gh","symbol":"encode","correct":"import geohash; geohash.encode(lat, lng)"},{"note":"The package name for installation is 'python-geohash', but the import module name is 'geohash'.","symbol":"decode","correct":"import geohash; geohash.decode(geohash_string)"},{"note":"For working with 64-bit integer geohash representation, introduced in version 0.8.","symbol":"encode_uint64","correct":"import geohash; geohash.encode_uint64(lat, lng)"},{"note":"For decoding 64-bit integer geohash representation.","symbol":"decode_uint64","correct":"import geohash; geohash.decode_uint64(uint64_hash)"}],"quickstart":{"code":"import geohash\n\n# Encode coordinates to a geohash string with default precision (12 characters)\nlatitude, longitude = 42.6, -5.6\ngeohash_string = geohash.encode(latitude, longitude)\nprint(f\"Encoded geohash: {geohash_string}\")\n\n# Encode with custom precision\nshort_geohash = geohash.encode(latitude, longitude, precision=5)\nprint(f\"Short geohash (precision 5): {short_geohash}\")\n\n# Decode a geohash string back to coordinates\ndecoded_lat, decoded_lng = geohash.decode(geohash_string)\nprint(f\"Decoded coordinates: ({decoded_lat}, {decoded_lng})\")\n\n# Example with uint64 representation\nuint64_hash = geohash.encode_uint64(latitude, longitude)\nprint(f\"Encoded uint64 geohash: {uint64_hash}\")\ndecoded_lat_uint64, decoded_lng_uint64 = geohash.decode_uint64(uint64_hash)\nprint(f\"Decoded uint64 coordinates: ({decoded_lat_uint64}, {decoded_lng_uint64})\")","lang":"python","description":"This quickstart demonstrates how to encode latitude and longitude coordinates into geohash strings, control the precision, and decode geohash strings back into coordinates using the `geohash` module. It also shows the usage of `uint64` representation for integer-based geohashing."},"warnings":[{"fix":"Migrate to a maintained library such as `pygeohash` (`pip install pygeohash`).","message":"This library (python-geohash 0.8.5) is largely unmaintained since its last update in 2014. Users are strongly advised to consider more actively developed and modern alternatives like the 'pygeohash' library (lowercase 'p' in package name) for current projects, which offers Python 3 support, zero dependencies, and performance optimizations.","severity":"breaking","affected_versions":"0.8.5 and older"},{"fix":"Ensure a C/C++ compiler is installed and properly configured, or consider using the pure Python fallback if the C extension fails to build (though this library's pure Python mode might still be slow compared to modern alternatives). Migrating to `pygeohash` (which has its own optimized CPython core) is the recommended solution.","message":"Installation issues with the optional C extension are common on modern operating systems (e.g., macOS with newer Python versions), potentially leading to `command 'g++' failed with exit status 1` errors during `pip install`. The library can fall back to a pure Python implementation, but this might result in a silent performance degradation or complete installation failure.","severity":"gotcha","affected_versions":"0.8.5"},{"fix":"Adjust code to handle the direct float return values. If migrating, review the decoding output format of the new library carefully.","message":"The `decode()` function returns raw float values for latitude and longitude. Some other geohash libraries might return a tuple with error margins or a custom object, which could lead to incompatibility if migrating between libraries or expecting a specific structured output.","severity":"gotcha","affected_versions":"0.8.5"},{"fix":"For precise proximity searches, supplement geohash prefix matching with bounding box queries or actual distance calculations for candidate geohashes, rather than relying solely on shared prefixes.","message":"Geohashes, by nature, can sometimes represent geographically close points with different prefixes if they fall on opposite sides of a geohash grid boundary. This can affect proximity search logic based solely on prefix matching.","severity":"gotcha","affected_versions":"All versions (inherent to Geohash algorithm)"}],"env_vars":null,"last_verified":"2026-04-11T00:00:00.000Z","next_check":"2026-07-10T00:00:00.000Z"}