h3-py
Python bindings for the H3 Core Library.
For API reference, see the H3 Documentation.
Installation
From PyPI:
pip install h3
From conda:
conda config --add channels conda-forge
conda install h3-py
New since v3.6.1: We upload pre-built Python Wheels to PyPI for Linux/Mac/Windows, which should avoid many previous installation issues.
Usage
>>> import h3
>>> lat, lng = 0, 0
>>> resolution = 0
>>> h3.geo_to_h3(lat, lng, resolution)
'8075fffffffffff'
Example gallery
Browse a collection of example notebooks, and if you have examples or visualizations of your own, please feel free to contribute!
We also have a simple walkthrough of the API. For more information, please see the H3 Documentation.
APIs
We provide multiple APIs in h3-py.
All APIs have the same set of functions, but differ
in their input/output formats.
h3.api.basic_str
H3 indexes are represented as Python strs, using list and set for collections.
This is the default API provided when you import h3.
That is, import h3.api.basic_str as h3 and import h3
are basically equivalent.
>>> import h3
>>> h = h3.geo_to_h3(0, 0, 0)
>>> h
'8075fffffffffff'
>>> h3.hex_ring(h, 1)
{'8055fffffffffff',
'8059fffffffffff',
'807dfffffffffff',
'8083fffffffffff',
'8099fffffffffff'}
h3.api.basic_int
H3 indexes are represented as Python ints, using list and set for collections.
>>> import h3.api.basic_int as h3
>>> h = h3.geo_to_h3(0, 0, 0)
>>> h
578536630256664575
>>> h3.hex_ring(h, 1)
{577973680303243263,
578044049047420927,
578677367745019903,
578782920861286399,
579169948954263551}
h3.api.numpy_int
H3 indexes are represented as uint64s, using numpy.ndarray
for collections.
The intention is for this API to be faster and more memory-efficient by
not requiring int to str conversion and by using
no-copy numpy arrays instead of Python lists and sets.
>>> import h3.api.numpy_int as h3
>>> h = h3.geo_to_h3(0, 0, 0)
>>> h
578536630256664575
>>> h3.hex_ring(h, 1)
array([578782920861286399, 578044049047420927, 577973680303243263,
578677367745019903, 579169948954263551], dtype=uint64)
Note that h3 has no runtime dependencies on other libraries, so a standard
pip install will install no additional libraries.
However, h3.api.numpy_int requires numpy. To have numpy installed (if it isn't already) along
with h3, run pip install h3[numpy].
h3.api.memview_int
H3 indexes are represented as uint64s, using Python
memoryview objects
for collections.
This API has the same benefits as numpy_int, except it uses
(the less well-known but dependency-free) memoryview.
>>> import h3.api.memview_int as h3
>>> h = h3.geo_to_h3(0, 0, 0)
>>> h
578536630256664575
>>> mv = h3.hex_ring(h, 1)
>>> mv
<MemoryView of 'array' at 0x11188c710>
>>> mv[0]
578782920861286399
>>> list(mv)
[578782920861286399,
578044049047420927,
577973680303243263,
578677367745019903,
579169948954263551]
When using this API with numpy, note that numpy.array creates a copy
of the data, while numpy.asarray does not create a copy and the
result points to the same memory location as the memoryview object.
Continuing from the example above,
>>> mv = h3.hex_ring(h, 1)
>>> a = np.array(mv)
>>> mv[0] = 0
>>> a
array([578782920861286399, 578044049047420927, 577973680303243263,
578677367745019903, 579169948954263551], dtype=uint64)
>>> mv = h3.hex_ring(h, 1)
>>> a = np.asarray(mv)
>>> mv[0] = 0
>>> a
array([ 0, 578044049047420927, 577973680303243263,
578677367745019903, 579169948954263551], dtype=uint64)
Versioning
h3-py wraps the H3 Core Library,
which is written in C.
Both projects employ semantic versioning,
with versions taking the form X.Y.Z.
h3-py will match the C library
in major and minor numbers (X.Y), but may be different on the
patch (Z) number.
Use h3.versions() to see the version numbers for both
h3-py and the C library. For example,
>>> import h3
>>> h3.versions()
{'c': '3.6.3', 'python': '3.6.1'}
Release files for h3 3.7.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| h3-3.7.0.tar.gz | 17.3 MB | Details |
Built distributions (wheels)
| File | Reset | |||
|---|---|---|---|---|
| h3-3.7.0-cp39-cp39-win_amd64.whl | CPython 3.9 | CPython 3.9 | Windows x86-64 | Details |
| h3-3.7.0-cp39-cp39-manylinux2010_x86_64.whl | CPython 3.9 | CPython 3.9 | Linux glibc 2.12+ x86-64 | Details |
| h3-3.7.0-cp38-cp38-win_amd64.whl | CPython 3.8 | CPython 3.8 | Windows x86-64 | Details |
| h3-3.7.0-cp38-cp38-manylinux2010_x86_64.whl | CPython 3.8 | CPython 3.8 | Linux glibc 2.12+ x86-64 | Details |
| h3-3.7.0-cp38-cp38-macosx_10_9_x86_64.whl | CPython 3.8 | CPython 3.8 | macOS 10.9+ x86-64 | Details |
| h3-3.7.0-cp37-cp37m-win_amd64.whl | CPython 3.7 | CPython 3.7 pymalloc | Windows x86-64 | Details |
| h3-3.7.0-cp37-cp37m-manylinux2010_x86_64.whl | CPython 3.7 | CPython 3.7 pymalloc | Linux glibc 2.12+ x86-64 | Details |
| h3-3.7.0-cp37-cp37m-macosx_10_9_x86_64.whl | CPython 3.7 | CPython 3.7 pymalloc | macOS 10.9+ x86-64 | Details |
| h3-3.7.0-cp36-cp36m-win_amd64.whl | CPython 3.6 | CPython 3.6 pymalloc | Windows x86-64 | Details |
| h3-3.7.0-cp36-cp36m-manylinux2010_x86_64.whl | CPython 3.6 | CPython 3.6 pymalloc | Linux glibc 2.12+ x86-64 | Details |
| h3-3.7.0-cp36-cp36m-macosx_10_9_x86_64.whl | CPython 3.6 | CPython 3.6 pymalloc | macOS 10.9+ x86-64 | Details |
| h3-3.7.0-cp35-cp35m-win_amd64.whl | CPython 3.5 | CPython 3.5 pymalloc | Windows x86-64 | Details |
| h3-3.7.0-cp35-cp35m-manylinux2010_x86_64.whl | CPython 3.5 | CPython 3.5 pymalloc | Linux glibc 2.12+ x86-64 | Details |
| h3-3.7.0-cp35-cp35m-macosx_10_9_x86_64.whl | CPython 3.5 | CPython 3.5 pymalloc | macOS 10.9+ x86-64 | Details |
| h3-3.7.0-cp27-cp27mu-manylinux2010_x86_64.whl | CPython 2.7 | CPython 2.7 pymalloc wide-unicode | Linux glibc 2.12+ x86-64 | Details |
| h3-3.7.0-cp27-cp27m-manylinux2010_x86_64.whl | CPython 2.7 | CPython 2.7 pymalloc | Linux glibc 2.12+ x86-64 | Details |
| h3-3.7.0-cp27-cp27m-macosx_10_9_x86_64.whl | CPython 2.7 | CPython 2.7 pymalloc | macOS 10.9+ x86-64 | Details |
Total release size:29.1 MB
Release files / h3-3.7.0.tar.gz
| Download URL | h3-3.7.0.tar.gz |
|---|---|
| Size | 17.3 MB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
cd27fc8ecd9183f93934079b7c986401f499030ff2e2171eace9de462fab561d
|
|
BLAKE2b-256 checksum How to use checksums |
8012a126cd8a96595146de648b1085059d716bbc0cddb52ba7a427138ccf6da7
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.2.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/47.1.0 requests-toolbelt/0.9.1 tqdm/4.50.0 CPython/3.8.5
|
Release files / h3-3.7.0-cp39-cp39-win_amd64.whl
| Download URL | h3-3.7.0-cp39-cp39-win_amd64.whl |
|---|---|
| Size | 575.1 kB |
| Tags | CPython 3.9 Windows x86-64 |
|
SHA-256 checksum How to use checksums |
b9617221472d1ea856b388dcd2916e6745169235945a55d970a35a8a0866bf40
|
|
BLAKE2b-256 checksum How to use checksums |
e61440008d9a9342178d0011cef863c6c8943d094c6a9de11a870e47fc4fe0d6
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.2.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/47.1.0 requests-toolbelt/0.9.1 tqdm/4.50.0 CPython/3.8.5
|
Release files / h3-3.7.0-cp39-cp39-manylinux2010_x86_64.whl
| Download URL | h3-3.7.0-cp39-cp39-manylinux2010_x86_64.whl |
|---|---|
| Size | 802.5 kB |
| Tags | CPython 3.9 Linux glibc 2.12+ x86-64 |
|
SHA-256 checksum How to use checksums |
0a09d85c98230509556f9715613271ae1a4bcfbf3c99ad1e9702638edaaaa8f0
|
|
BLAKE2b-256 checksum How to use checksums |
84e04610f980cf797f894de9895751321d3c1ab036af2c4c32b7c7155258d9ac
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.2.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/47.1.0 requests-toolbelt/0.9.1 tqdm/4.50.0 CPython/3.8.5
|
Release files / h3-3.7.0-cp38-cp38-win_amd64.whl
| Download URL | h3-3.7.0-cp38-cp38-win_amd64.whl |
|---|---|
| Size | 575.0 kB |
| Tags | CPython 3.8 Windows x86-64 |
|
SHA-256 checksum How to use checksums |
afb87102dfd3d6b4b89ccb96eae9be98658c4256658e093c5623daa2e161dbef
|
|
BLAKE2b-256 checksum How to use checksums |
f99b45e2f74423fb8a035acc33dd3f8ddd2f56750539142a1cc647fe8f8b2c6d
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.2.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/47.1.0 requests-toolbelt/0.9.1 tqdm/4.50.0 CPython/3.8.5
|
Release files / h3-3.7.0-cp38-cp38-manylinux2010_x86_64.whl
| Download URL | h3-3.7.0-cp38-cp38-manylinux2010_x86_64.whl |
|---|---|
| Size | 802.4 kB |
| Tags | CPython 3.8 Linux glibc 2.12+ x86-64 |
|
SHA-256 checksum How to use checksums |
0eebbf4600446ad78c0416482cd6cd3d86383387adbbe3ce30a88418df4496a4
|
|
BLAKE2b-256 checksum How to use checksums |
77e93638a4c9c59eb960d166ef98c9bdb579ee46c1fef5ad3cb1c319b95554fd
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.2.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/47.1.0 requests-toolbelt/0.9.1 tqdm/4.50.0 CPython/3.8.5
|
Release files / h3-3.7.0-cp38-cp38-macosx_10_9_x86_64.whl
| Download URL | h3-3.7.0-cp38-cp38-macosx_10_9_x86_64.whl |
|---|---|
| Size | 685.4 kB |
| Tags | CPython 3.8 macOS 10.9+ x86-64 |
|
SHA-256 checksum How to use checksums |
ac6ec8dfb3bd67e32b9b3707ed72b30149dcc3cddb6ce18cb12312b94b57e155
|
|
BLAKE2b-256 checksum How to use checksums |
a9e6047d0bbd663bb7cba53c82ff9339c75e2bd5ebb262bda6d6cdebb6535fcc
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.2.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/47.1.0 requests-toolbelt/0.9.1 tqdm/4.50.0 CPython/3.8.5
|
Release files / h3-3.7.0-cp37-cp37m-win_amd64.whl
| Download URL | h3-3.7.0-cp37-cp37m-win_amd64.whl |
|---|---|
| Size | 568.4 kB |
| Tags | CPython 3.7 CPython 3.7 pymalloc Windows x86-64 |
|
SHA-256 checksum How to use checksums |
905dc33286ffdab67cf9df9b04b33be2c3c9b6a5fa3166f789d760d775a4677d
|
|
BLAKE2b-256 checksum How to use checksums |
4903c66bbf4c14bb11d1019f1c32e178f62b1523621f680eea543c287b300ed6
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.2.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/47.1.0 requests-toolbelt/0.9.1 tqdm/4.50.0 CPython/3.8.5
|
Release files / h3-3.7.0-cp37-cp37m-manylinux2010_x86_64.whl
| Download URL | h3-3.7.0-cp37-cp37m-manylinux2010_x86_64.whl |
|---|---|
| Size | 790.8 kB |
| Tags | CPython 3.7 CPython 3.7 pymalloc Linux glibc 2.12+ x86-64 |
|
SHA-256 checksum How to use checksums |
b92b0d4a6c77513e792d75fa1e2e895f873eec11b16eb9b9f46b1174f21ada95
|
|
BLAKE2b-256 checksum How to use checksums |
746cf23a24064f2c0ffbef234c0c1d7f7655c4317d749d27bea1074d963554b0
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.2.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/47.1.0 requests-toolbelt/0.9.1 tqdm/4.50.0 CPython/3.8.5
|
Release files / h3-3.7.0-cp37-cp37m-macosx_10_9_x86_64.whl
| Download URL | h3-3.7.0-cp37-cp37m-macosx_10_9_x86_64.whl |
|---|---|
| Size | 688.6 kB |
| Tags | CPython 3.7 CPython 3.7 pymalloc macOS 10.9+ x86-64 |
|
SHA-256 checksum How to use checksums |
683fafdbf32d10862e874b939c818a4f11c67e4a48afc26cafc43854a97a0254
|
|
BLAKE2b-256 checksum How to use checksums |
c04ab9d05d8df8f186e8f98c7c09b9b673ea0ca211657fe1ef32ec78cb69f179
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.2.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/47.1.0 requests-toolbelt/0.9.1 tqdm/4.50.0 CPython/3.8.5
|
Release files / h3-3.7.0-cp36-cp36m-win_amd64.whl
| Download URL | h3-3.7.0-cp36-cp36m-win_amd64.whl |
|---|---|
| Size | 568.4 kB |
| Tags | CPython 3.6 CPython 3.6 pymalloc Windows x86-64 |
|
SHA-256 checksum How to use checksums |
fbd3a37a54a72c19504dc0c39f1d5aa8338ee774ede9e9a8e8045a88e94dc857
|
|
BLAKE2b-256 checksum How to use checksums |
11ba26f899d93aa55cb058e16a13bce9e79c00b6640060495078a1fba3e770dc
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.2.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/47.1.0 requests-toolbelt/0.9.1 tqdm/4.50.0 CPython/3.8.5
|
Release files / h3-3.7.0-cp36-cp36m-manylinux2010_x86_64.whl
| Download URL | h3-3.7.0-cp36-cp36m-manylinux2010_x86_64.whl |
|---|---|
| Size | 792.4 kB |
| Tags | CPython 3.6 CPython 3.6 pymalloc Linux glibc 2.12+ x86-64 |
|
SHA-256 checksum How to use checksums |
155b4b4ceb22f24b48e88c596860123ec1aa60e2b62994ea2b557ba553a90435
|
|
BLAKE2b-256 checksum How to use checksums |
629b426e47f1a569dd37a6b6026b61a7926557d5c3222da28bcc991618a66a17
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.2.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/47.1.0 requests-toolbelt/0.9.1 tqdm/4.50.0 CPython/3.8.5
|
Release files / h3-3.7.0-cp36-cp36m-macosx_10_9_x86_64.whl
| Download URL | h3-3.7.0-cp36-cp36m-macosx_10_9_x86_64.whl |
|---|---|
| Size | 687.9 kB |
| Tags | CPython 3.6 CPython 3.6 pymalloc macOS 10.9+ x86-64 |
|
SHA-256 checksum How to use checksums |
aeee8247c312d671d5d3d77f277b6a6f70db9077a9194ca5ab7c597e50188cc6
|
|
BLAKE2b-256 checksum How to use checksums |
44726735f854a5c3293fbde34b4328a9fc87cd13c6569c658bce31aff4247ddd
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.2.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/47.1.0 requests-toolbelt/0.9.1 tqdm/4.50.0 CPython/3.8.5
|
Release files / h3-3.7.0-cp35-cp35m-win_amd64.whl
| Download URL | h3-3.7.0-cp35-cp35m-win_amd64.whl |
|---|---|
| Size | 563.5 kB |
| Tags | CPython 3.5 CPython 3.5 pymalloc Windows x86-64 |
|
SHA-256 checksum How to use checksums |
119b1b1dae60177195d5804c1058a3eeaf1f954dbeaa4920100347994a99f2d5
|
|
BLAKE2b-256 checksum How to use checksums |
db7e9874bba767027f8e02aca48e760ad818c7b74cafe68af7ffac1af46cc124
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.2.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/47.1.0 requests-toolbelt/0.9.1 tqdm/4.50.0 CPython/3.8.5
|
Release files / h3-3.7.0-cp35-cp35m-manylinux2010_x86_64.whl
| Download URL | h3-3.7.0-cp35-cp35m-manylinux2010_x86_64.whl |
|---|---|
| Size | 786.9 kB |
| Tags | CPython 3.5 CPython 3.5 pymalloc Linux glibc 2.12+ x86-64 |
|
SHA-256 checksum How to use checksums |
317c5a3101c61e9260c47364fee2552e75ff0c0a44b0be59393ff48f7cdb129c
|
|
BLAKE2b-256 checksum How to use checksums |
38b71aec3f2c6e90d5101ef7a5cacc60151ccab4f37495d3c2df09b728cbec25
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.2.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/47.1.0 requests-toolbelt/0.9.1 tqdm/4.50.0 CPython/3.8.5
|
Release files / h3-3.7.0-cp35-cp35m-macosx_10_9_x86_64.whl
| Download URL | h3-3.7.0-cp35-cp35m-macosx_10_9_x86_64.whl |
|---|---|
| Size | 680.6 kB |
| Tags | CPython 3.5 CPython 3.5 pymalloc macOS 10.9+ x86-64 |
|
SHA-256 checksum How to use checksums |
08bd10c2f099f436fa2034c7364a445f5aa58f2926deb524f94562a6b8e91ffe
|
|
BLAKE2b-256 checksum How to use checksums |
8c23171104ca51824d44735defd77647eb77857cab6f3e7ef30bad4ac68405ea
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.2.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/47.1.0 requests-toolbelt/0.9.1 tqdm/4.50.0 CPython/3.8.5
|
Release files / h3-3.7.0-cp27-cp27mu-manylinux2010_x86_64.whl
| Download URL | h3-3.7.0-cp27-cp27mu-manylinux2010_x86_64.whl |
|---|---|
| Size | 781.8 kB |
| Tags | CPython 2.7 CPython 2.7 pymalloc wide-unicode Linux glibc 2.12+ x86-64 |
|
SHA-256 checksum How to use checksums |
73bf98eaf127200825b1f258b36cfba9e275b70866b8438c94eb145848c57e6b
|
|
BLAKE2b-256 checksum How to use checksums |
885c949bb984877169134e139584523870bee5d1843f53cbb76038e07768e7d3
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.2.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/47.1.0 requests-toolbelt/0.9.1 tqdm/4.50.0 CPython/3.8.5
|
Release files / h3-3.7.0-cp27-cp27m-manylinux2010_x86_64.whl
| Download URL | h3-3.7.0-cp27-cp27m-manylinux2010_x86_64.whl |
|---|---|
| Size | 781.8 kB |
| Tags | CPython 2.7 CPython 2.7 pymalloc Linux glibc 2.12+ x86-64 |
|
SHA-256 checksum How to use checksums |
b5cbdfccf12d6f2ccdd5589ce0e5b953cb90a35c1070ac813d09a0dd7220b758
|
|
BLAKE2b-256 checksum How to use checksums |
8681d23b23be258df749b50334a426536567f4d0147e5a223748536f12827cc6
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.2.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/47.1.0 requests-toolbelt/0.9.1 tqdm/4.50.0 CPython/3.8.5
|
Release files / h3-3.7.0-cp27-cp27m-macosx_10_9_x86_64.whl
| Download URL | h3-3.7.0-cp27-cp27m-macosx_10_9_x86_64.whl |
|---|---|
| Size | 699.5 kB |
| Tags | CPython 2.7 CPython 2.7 pymalloc macOS 10.9+ x86-64 |
|
SHA-256 checksum How to use checksums |
920e977ca51319c857998c88481d137297b5ec078672a82cb5a6dafcda44fcda
|
|
BLAKE2b-256 checksum How to use checksums |
8459b13e9cbfbb9aab6f3a8aea89ebf59402c857b781dc84ae59abe204d324c3
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.2.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/47.1.0 requests-toolbelt/0.9.1 tqdm/4.50.0 CPython/3.8.5
|