Hierarchical hexagonal geospatial indexing system
Project description
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 str
s, 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 int
s, 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 uint64
s, 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 list
s and set
s.
>>> 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 uint64
s, 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'}
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distributions
File details
Details for the file h3-3.7.1.tar.gz
.
File metadata
- Download URL: h3-3.7.1.tar.gz
- Upload date:
- Size: 17.3 MB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.2.0 pkginfo/1.6.1 requests/2.25.1 setuptools/49.2.1 requests-toolbelt/0.9.1 tqdm/4.54.1 CPython/3.8.6
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 8097ea0db0c0fa9bdfe161940c196f6e5ef499afc1033fa98f85e7968700ea9a |
|
MD5 | cb2e0ebff7917a1eacd54be184fa1b8a |
|
BLAKE2b-256 | 9d646fc400d61e98782590689a837d82e5f0280ffd4ad61fb85c83eaea7fd52a |
Provenance
File details
Details for the file h3-3.7.1-cp39-cp39-win_amd64.whl
.
File metadata
- Download URL: h3-3.7.1-cp39-cp39-win_amd64.whl
- Upload date:
- Size: 575.6 kB
- Tags: CPython 3.9, Windows x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.2.0 pkginfo/1.6.1 requests/2.25.1 setuptools/49.2.1 requests-toolbelt/0.9.1 tqdm/4.54.1 CPython/3.8.6
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | b56172d64da8b2e7649cc4745cf857bb933af61d1a67c0eca86dc6aa36edb64b |
|
MD5 | f45409c833edd4f82cf8350b1b33a9fb |
|
BLAKE2b-256 | 4b5867037869fa0719fcd5531b13aa8fdb971f2f5fe9cff6105cd7631c79cd64 |
Provenance
File details
Details for the file h3-3.7.1-cp39-cp39-manylinux2010_x86_64.whl
.
File metadata
- Download URL: h3-3.7.1-cp39-cp39-manylinux2010_x86_64.whl
- Upload date:
- Size: 803.3 kB
- Tags: CPython 3.9, manylinux: glibc 2.12+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.2.0 pkginfo/1.6.1 requests/2.25.1 setuptools/49.2.1 requests-toolbelt/0.9.1 tqdm/4.54.1 CPython/3.8.6
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 4505eac85301989bb0147eea4b45306075faaa5e720fb631da68d9fa463b1de3 |
|
MD5 | 8523db749df83a98aee1897c85af93d2 |
|
BLAKE2b-256 | b5431cdd4f7cbc313aa7ae15315deb4a359fecf27d9b9f98f3ac5fea72959721 |
Provenance
File details
Details for the file h3-3.7.1-cp39-cp39-macosx_10_9_x86_64.whl
.
File metadata
- Download URL: h3-3.7.1-cp39-cp39-macosx_10_9_x86_64.whl
- Upload date:
- Size: 685.0 kB
- Tags: CPython 3.9, macOS 10.9+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.2.0 pkginfo/1.6.1 requests/2.25.1 setuptools/49.2.1 requests-toolbelt/0.9.1 tqdm/4.54.1 CPython/3.8.6
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 7a41374fa1e92a4a6703f0f96d4e3b42fe04619d4617f9996ad46271d0873257 |
|
MD5 | abca048f6ca89db4ef07184dbfea565f |
|
BLAKE2b-256 | f7fbae52a4c06e9cae1e186565915894a9617fa79d9d74dc328880f2ffab5a7a |
Provenance
File details
Details for the file h3-3.7.1-cp38-cp38-win_amd64.whl
.
File metadata
- Download URL: h3-3.7.1-cp38-cp38-win_amd64.whl
- Upload date:
- Size: 575.3 kB
- Tags: CPython 3.8, Windows x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.2.0 pkginfo/1.6.1 requests/2.25.1 setuptools/49.2.1 requests-toolbelt/0.9.1 tqdm/4.54.1 CPython/3.8.6
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 836764447995ad4326914250007612ead63e2a2324292f82a93786afb411d283 |
|
MD5 | 14bcb5c7fc5b3ebdddbd906f54cb55b4 |
|
BLAKE2b-256 | 232400e2ac3da57047cfdc15229c2b1b44b8cee8a8a26cf05368213fbab1b66b |
Provenance
File details
Details for the file h3-3.7.1-cp38-cp38-manylinux2010_x86_64.whl
.
File metadata
- Download URL: h3-3.7.1-cp38-cp38-manylinux2010_x86_64.whl
- Upload date:
- Size: 803.2 kB
- Tags: CPython 3.8, manylinux: glibc 2.12+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.2.0 pkginfo/1.6.1 requests/2.25.1 setuptools/49.2.1 requests-toolbelt/0.9.1 tqdm/4.54.1 CPython/3.8.6
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 93ff92b5a5cfc7cfe7331ea9823a5bcb5ead18d895dbb98580ac247c15e3f1ca |
|
MD5 | 535eae3c57f25c4ecd988a5ed1ac1ea6 |
|
BLAKE2b-256 | 52e1b141962a91721e4e83bc510e5044a5bfa0674f8b7fa36af96f577f4ae492 |
Provenance
File details
Details for the file h3-3.7.1-cp38-cp38-macosx_10_9_x86_64.whl
.
File metadata
- Download URL: h3-3.7.1-cp38-cp38-macosx_10_9_x86_64.whl
- Upload date:
- Size: 673.4 kB
- Tags: CPython 3.8, macOS 10.9+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.2.0 pkginfo/1.6.1 requests/2.25.1 setuptools/49.2.1 requests-toolbelt/0.9.1 tqdm/4.54.1 CPython/3.8.6
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 56f831311553eb19ac4b6739e6faf2fb4ed648e53756cd1be9807527d03008d4 |
|
MD5 | 9f0a42671b243a1465fc3bf9ec20234d |
|
BLAKE2b-256 | 29dfd236d5fca7bec90463fa3c1662133fe8f904fc1728b3acb323b1ae419485 |
Provenance
File details
Details for the file h3-3.7.1-cp37-cp37m-win_amd64.whl
.
File metadata
- Download URL: h3-3.7.1-cp37-cp37m-win_amd64.whl
- Upload date:
- Size: 568.9 kB
- Tags: CPython 3.7m, Windows x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.2.0 pkginfo/1.6.1 requests/2.25.1 setuptools/49.2.1 requests-toolbelt/0.9.1 tqdm/4.54.1 CPython/3.8.6
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | b27b65e5776ca626defa030f4dc36a84c50ef11458d6f8293c52ef02e4092799 |
|
MD5 | a4ca486bae67af2b6ee1436fb34e306a |
|
BLAKE2b-256 | 2db230349363cf618e5c44f7e087806126752d01c866820060d6eab5dcae90ec |
Provenance
File details
Details for the file h3-3.7.1-cp37-cp37m-manylinux2010_x86_64.whl
.
File metadata
- Download URL: h3-3.7.1-cp37-cp37m-manylinux2010_x86_64.whl
- Upload date:
- Size: 791.8 kB
- Tags: CPython 3.7m, manylinux: glibc 2.12+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.2.0 pkginfo/1.6.1 requests/2.25.1 setuptools/49.2.1 requests-toolbelt/0.9.1 tqdm/4.54.1 CPython/3.8.6
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 451a672640dab586c9327acce7bee0c79d214e4514c9e39c6c131f9ab87677d4 |
|
MD5 | 446cdc40c72aef89b661e4ce51c8505e |
|
BLAKE2b-256 | aa30939883d5e107031ee49d70c3442c79ae8cd68d7c6ecf8845c8d59edb629d |
Provenance
File details
Details for the file h3-3.7.1-cp37-cp37m-macosx_10_9_x86_64.whl
.
File metadata
- Download URL: h3-3.7.1-cp37-cp37m-macosx_10_9_x86_64.whl
- Upload date:
- Size: 676.1 kB
- Tags: CPython 3.7m, macOS 10.9+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.2.0 pkginfo/1.6.1 requests/2.25.1 setuptools/49.2.1 requests-toolbelt/0.9.1 tqdm/4.54.1 CPython/3.8.6
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | a2c549e9483d0f5a8d00928e4a415e19ab4d41d798389e9a3f45f7c48543fbdc |
|
MD5 | afb9fb98d11cc879ed713cd05bbdb5cd |
|
BLAKE2b-256 | 3c2f6c965ce688d2942a40235951dd558e675a53b723ba80d36b1853a1009058 |
Provenance
File details
Details for the file h3-3.7.1-cp36-cp36m-win_amd64.whl
.
File metadata
- Download URL: h3-3.7.1-cp36-cp36m-win_amd64.whl
- Upload date:
- Size: 568.9 kB
- Tags: CPython 3.6m, Windows x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.2.0 pkginfo/1.6.1 requests/2.25.1 setuptools/49.2.1 requests-toolbelt/0.9.1 tqdm/4.54.1 CPython/3.8.6
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | f692e8207a0b8307003b14a4f00928c234920f85664fc964b1fac641b6e5039b |
|
MD5 | 1049ab26fa1b065794aedcdae3fc076c |
|
BLAKE2b-256 | dbefa0b9c99096f5e7f43f6abeec25e249ffd3d97454718a462d2dfb2fa84533 |
Provenance
File details
Details for the file h3-3.7.1-cp36-cp36m-manylinux2010_x86_64.whl
.
File metadata
- Download URL: h3-3.7.1-cp36-cp36m-manylinux2010_x86_64.whl
- Upload date:
- Size: 793.4 kB
- Tags: CPython 3.6m, manylinux: glibc 2.12+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.2.0 pkginfo/1.6.1 requests/2.25.1 setuptools/49.2.1 requests-toolbelt/0.9.1 tqdm/4.54.1 CPython/3.8.6
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 96bd7ce85164430cff27fba6c80df017afb58cd06171e26e9b91a2b6741863c8 |
|
MD5 | 98bd3f18d645f16f8489087a3e36987a |
|
BLAKE2b-256 | fde7cf4b5baef8579d9c0be39b2df81059f2538ac427c3297bcffdf4e35989ab |
Provenance
File details
Details for the file h3-3.7.1-cp36-cp36m-macosx_10_9_x86_64.whl
.
File metadata
- Download URL: h3-3.7.1-cp36-cp36m-macosx_10_9_x86_64.whl
- Upload date:
- Size: 675.6 kB
- Tags: CPython 3.6m, macOS 10.9+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.2.0 pkginfo/1.6.1 requests/2.25.1 setuptools/49.2.1 requests-toolbelt/0.9.1 tqdm/4.54.1 CPython/3.8.6
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | a600a2545e945b9858bc6485e9c4dfeee1bfeb6c0f136a488ab3fb3dff785a01 |
|
MD5 | 1e06f437bb4e4e9ca9b374dc92c2140a |
|
BLAKE2b-256 | 49da014dcadcd95c0ac2cb989036ac30b054e0b3e189ad0ec2326b85080cfab8 |
Provenance
File details
Details for the file h3-3.7.1-cp35-cp35m-win_amd64.whl
.
File metadata
- Download URL: h3-3.7.1-cp35-cp35m-win_amd64.whl
- Upload date:
- Size: 563.9 kB
- Tags: CPython 3.5m, Windows x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.2.0 pkginfo/1.6.1 requests/2.25.1 setuptools/49.2.1 requests-toolbelt/0.9.1 tqdm/4.54.1 CPython/3.8.6
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | bda2b977fa8953f0f9c8a30c3f4cfc4ba864450a1ae402531da670030c8c1aff |
|
MD5 | 07c01e3d5a6cf03c3fc5cf4f86b3fe1d |
|
BLAKE2b-256 | 01f674632ac632e13bf15ae01806eb88d023d28c58c22fa54fbb6c6b8a493523 |
Provenance
File details
Details for the file h3-3.7.1-cp35-cp35m-manylinux2010_x86_64.whl
.
File metadata
- Download URL: h3-3.7.1-cp35-cp35m-manylinux2010_x86_64.whl
- Upload date:
- Size: 787.1 kB
- Tags: CPython 3.5m, manylinux: glibc 2.12+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.2.0 pkginfo/1.6.1 requests/2.25.1 setuptools/49.2.1 requests-toolbelt/0.9.1 tqdm/4.54.1 CPython/3.8.6
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | daaf9cff9dc6e0416ac0860c7ad3a4ec41f9a8798e9855c455da79775e5e28ae |
|
MD5 | 8a5c7f6cec699877dd44118427f370a8 |
|
BLAKE2b-256 | f2e40ab5eb0b32e465547c17b0516c6f9b6ab7f13f9820db17f40c8578d01f85 |
Provenance
File details
Details for the file h3-3.7.1-cp35-cp35m-macosx_10_9_x86_64.whl
.
File metadata
- Download URL: h3-3.7.1-cp35-cp35m-macosx_10_9_x86_64.whl
- Upload date:
- Size: 668.9 kB
- Tags: CPython 3.5m, macOS 10.9+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.2.0 pkginfo/1.6.1 requests/2.25.1 setuptools/49.2.1 requests-toolbelt/0.9.1 tqdm/4.54.1 CPython/3.8.6
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 36d9291d655a68af269edc6f2c1d361cd838375ec69d9c47965e1c6735686e08 |
|
MD5 | 3cf9637d260d6854ff5b4dd383e17f0b |
|
BLAKE2b-256 | 17b0b3f58f4dc6cf9307ff4c180ecec08f6b06d845c5d293bdb07e5918ec873d |
Provenance
File details
Details for the file h3-3.7.1-cp27-cp27mu-manylinux2010_x86_64.whl
.
File metadata
- Download URL: h3-3.7.1-cp27-cp27mu-manylinux2010_x86_64.whl
- Upload date:
- Size: 782.9 kB
- Tags: CPython 2.7mu, manylinux: glibc 2.12+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.2.0 pkginfo/1.6.1 requests/2.25.1 setuptools/49.2.1 requests-toolbelt/0.9.1 tqdm/4.54.1 CPython/3.8.6
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 38f6ecf8d03b7b8a2ddb0fba3111bc69d6caec6dadb5a2f9d59193f341298dbf |
|
MD5 | 21695e96b18e372b8d52a62a610254a2 |
|
BLAKE2b-256 | b053fc761bb9fbf241e3fc3a35ddcb47572242408dc2ca8dc6eea39afe3e492f |
Provenance
File details
Details for the file h3-3.7.1-cp27-cp27m-manylinux2010_x86_64.whl
.
File metadata
- Download URL: h3-3.7.1-cp27-cp27m-manylinux2010_x86_64.whl
- Upload date:
- Size: 783.0 kB
- Tags: CPython 2.7m, manylinux: glibc 2.12+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.2.0 pkginfo/1.6.1 requests/2.25.1 setuptools/49.2.1 requests-toolbelt/0.9.1 tqdm/4.54.1 CPython/3.8.6
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 3e262d505520cb92a48a92b38fddc0bd7944b2292e1dd0e755e5b1c6c6b7caed |
|
MD5 | 97b8add10e74b4d42cce44f02da3ac58 |
|
BLAKE2b-256 | 801bdbbf7cd2efef901ac20a1ac4f9ad850cd271261e7ebdf6ac06dcbd83df0a |
Provenance
File details
Details for the file h3-3.7.1-cp27-cp27m-macosx_10_9_x86_64.whl
.
File metadata
- Download URL: h3-3.7.1-cp27-cp27m-macosx_10_9_x86_64.whl
- Upload date:
- Size: 685.8 kB
- Tags: CPython 2.7m, macOS 10.9+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.2.0 pkginfo/1.6.1 requests/2.25.1 setuptools/49.2.1 requests-toolbelt/0.9.1 tqdm/4.54.1 CPython/3.8.6
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 3c41c1a4f263de28991f123aac04b7ed9119658f453c37b4051187db34e1c62c |
|
MD5 | 518d49130ea036452c8ec7ca5efe7755 |
|
BLAKE2b-256 | 9cfc9ed8dcd76c8849977b3d9005a6ec0264740b05c1b80d1c8e87790acc3dd8 |