Skip to content
eudoxysPublic

About

Geocoding tools

Resources

Contributing

Stars

1 star

Watchers

1 watching

Forks

Repository files navigation

Validation Documentation

Eudoxys geohash tools

geohash encodes latitude/longitude positions as geohash codes and decodes codes back to the latitude and longitude of their cell centers, using the geohash algorithm of CTA-5009-A, Fast and Readable Geographical Hashing. It also gives great-circle distances in km between codes and finds the nearest code or position in a list. It provides a geohash command and a Python API for anyone who needs compact, prefix-nested location keys, and has no third-party dependencies.

Documentation

See https://www.eudoxys.com/geohash

Installation

Install using Eudoxys Package Manager:

pip install --upgrade eudoxys
epm install geohash

Install using pip:

pip install git+https://github.com/eudoxys/geohash

Note: the name geohash on PyPI belongs to an unrelated package, so pip install geohash without the URL installs the wrong package.

Maintenance

Update docs

make docs

This builds the pdoc site in docs/ (not committed). The Documentation workflow publishes it to https://www.eudoxys.com/geohash on each push to main that changes the package code.

Run tests

pip install -e . pytest
pytest

The tests need no credentials, network, or downloads, and run in under a second. See geohash/_test/README.md for what each test file checks.

Examples

Command line

geohash 9mtzm4 32.225646,-115.43884

prints

9mtzm4=32.22564697265625,-115.4388427734375
32.225646,-115.43884=9mtzm4

and

geohash -p 8 -f "{lat:.4f},{lon:.4f}" 32.225646,-115.43884 9mtzm4

prints

32.225646,-115.43884=9mtzm4kp
9mtzm4=32.2256,-115.4388

Run geohash --help for all options and exit codes.

Python

from geohash import geohash, geocode, distance, nearest
print(geohash(32.225646, -115.43884))
print(geocode("9mtzm4"))
print(round(distance("9q8yyk", "dr5reg"), 1))  # km
print(nearest("9q8yyk", ["dr5reg", "9q5ctr", "c23nb6"], withdist=True))

prints

9mtzm4
(32.22564697265625, -115.4388427734375)
4128.5
('9q5ctr', 558.749145533643)

Acknowledgments

  • This work was authored in part for the U.S. Department of Energy (DOE) by the National Laboratory of the Rockies under Contract No. DE-AC36-08GO28308 through a grant from the Grid Controls and Communications Devision and by Lawrence Livermore National Laboratory under Contract DE-AC52-07NA27344 through a grant from the Advanced Grid Modeling Program.

About

Geocoding tools

Resources

Contributing

Stars

1 star

Watchers

1 watching

Forks

Releases

Packages

Contributors

Languages