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
Hashes for h3-3.7.3-cp39-cp39-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | bd1982ab1f2a85517aae7166582b82c73e5350c31652f4ab20b337bcf978b43d |
|
MD5 | c443fbd8ab39754d35398c016f8862e6 |
|
BLAKE2b-256 | fd3dbf293fd53a479935e8e9adc6f21c15dce946d9af15b7402adbdbda684bf6 |
Hashes for h3-3.7.3-cp39-cp39-manylinux2014_aarch64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 950e833148ff441ee240d8ae71d4a32208cf062d9e0cc389fd056fc7cd280a0c |
|
MD5 | 37ef3dbe3b48053a4481693868ea41b8 |
|
BLAKE2b-256 | a114977925b276893c58939ce5de6cd8d87cc540e1a50f2cb2bf876b571e8f70 |
Hashes for h3-3.7.3-cp39-cp39-manylinux2010_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | f6f832c71b3b9be8949b299d20e8230129321d2296c28b970607d354cbce6efa |
|
MD5 | 0d6f61b705117637529e72bbf22ab8d4 |
|
BLAKE2b-256 | 9f6e89372ae53377b77a0db243eea1b43119b0445e49833feeac60a1bddaa70a |
Hashes for h3-3.7.3-cp39-cp39-macosx_10_9_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | e0467583c23164d232de51b82087685ab3c961911f673c892d10f87fd6642990 |
|
MD5 | 7ab23ef5c9a6eb12754d59dcb811ac0c |
|
BLAKE2b-256 | dc01952fc778842cfb8f71cdf96f9d18ddc8b62c8643216e817265c4e8cb805c |
Hashes for h3-3.7.3-cp38-cp38-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | de5d3bcc8f0253531ddf72e7305c6425b4af0c22921962ab7392a3c4c1dc5530 |
|
MD5 | f745fb817e930a9c5f2271dfe6365cbb |
|
BLAKE2b-256 | a75ad66e7145e6aa9b2892bcef9fe442511373de6e8ad608f5acc68919808db8 |
Hashes for h3-3.7.3-cp38-cp38-manylinux2014_aarch64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | e73ed07510907c8cf4e3a6f14625af221b0a3dea5c680ff011abec622cf2be9a |
|
MD5 | 57c1d8eae76b8208f4eb66c0db756a07 |
|
BLAKE2b-256 | 38c1efed7c7b4231dd8a12c46babce3cc9d4f6b1e4bc0945e05815b8d9c50d60 |
Hashes for h3-3.7.3-cp38-cp38-manylinux2010_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 7d6334b74e80a0e9395132bf9a7d38799b40df6181467616e950032a112773e9 |
|
MD5 | ae6b30dd43271c3b9a1bfd476b0b5d3f |
|
BLAKE2b-256 | 63613acdf125b93107ab22ff0377402648e6db889a1efe8fd79e1982d73fcb1f |
Hashes for h3-3.7.3-cp38-cp38-macosx_10_9_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 86b6bc6ac38f93be0899f45fb55585fb5c4964a2e5c8cc4a349cac41fecb10f3 |
|
MD5 | 106774d226ce8fb6d3cb2f5cc5e3d64b |
|
BLAKE2b-256 | c94f6ecf931fe7ac398ad6f6e438e056706b26cf82669cb8d737b0564f7dd804 |
Hashes for h3-3.7.3-cp37-cp37m-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 61ddf3052f226de22b546af5d47816d81fea83eb0e62d22f53ed3b23eb0b8551 |
|
MD5 | ab383241f61395b954a9c939b90cfa57 |
|
BLAKE2b-256 | c0b07b0c738f0f3993d74e40b358b47f41b257d2367819d10711cdacc57f6237 |
Hashes for h3-3.7.3-cp37-cp37m-manylinux2014_aarch64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 48274cff38d53da155500679194d69ce19aaa52c00d0f30f24a327c1b22cb752 |
|
MD5 | e9e00dd2330ae69439d7a018c1477ff3 |
|
BLAKE2b-256 | 8b182d837e4a15b956f5b2e734bffaeb4e1139619cb379ab205a06ca4e831c83 |
Hashes for h3-3.7.3-cp37-cp37m-manylinux2010_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 20d48a3c9acdcf7c02c70519c3a5a22406b505cc34ff9f9a302e11a2a13d9c73 |
|
MD5 | dd77da2b58d9af176c4e6f98a2e7aa3c |
|
BLAKE2b-256 | d3711c244f9bd73f89c06d0582460576aecd1df4a755879650c9393d2c18d742 |
Hashes for h3-3.7.3-cp37-cp37m-macosx_10_9_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 8acd1e448bad2f5cd03ab0107f34f34967dd271726978ed5acbe42806628d90a |
|
MD5 | 490d0cf98ac2ac16940e39d9a76e0522 |
|
BLAKE2b-256 | fd736e813ee3d30ed9a64449c70034aa92129ca7cdcd0f2711cd41a3028a2112 |
Hashes for h3-3.7.3-cp36-cp36m-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 1af9c039f7daeff4621c1349000eec0ed37c4548552a3a173cddb6d648547344 |
|
MD5 | 50507c127dee8b9223964e73a51d3fda |
|
BLAKE2b-256 | 82d32721856dd7b764d4e2f8cf83e1eb2f17d2e59d51055582427ccffad69d82 |
Hashes for h3-3.7.3-cp36-cp36m-manylinux2014_aarch64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 54e0f74357467347aee517d6137777094b64b9aac648d92a7507e14ac28ddca6 |
|
MD5 | 4b851e42c32529034b6da99222a7cbdc |
|
BLAKE2b-256 | 4fe37ecfa58c23855f64365547737223e8a805cf8e527bb3ceca91d50f23743f |
Hashes for h3-3.7.3-cp36-cp36m-manylinux2010_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 59abe06c99afa1b27bb7fcfb2a8c01d285ad36005dce8c82fca3dab0b4d8777d |
|
MD5 | 5279add97d4051ee53393bf14f6179b8 |
|
BLAKE2b-256 | bb4034b4725d30514bd26d6fd568623ff08b6025534b44b3030d6589cbc2e67f |
Hashes for h3-3.7.3-cp36-cp36m-macosx_10_9_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 339f4f210373dd43739019d6a8def64b119de62f3083e31b2d0413954c429c88 |
|
MD5 | aa454e5140f5b060debf7ee962b90d07 |
|
BLAKE2b-256 | 7d42e2353e1b92fceda8e3de762cd5285d93e0b74d60c02832b751821cf910d9 |
Hashes for h3-3.7.3-cp35-cp35m-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 83fb0a7e1a1241c9c69137569e761b257b9828abc24b8bf78710ddce8db9e28e |
|
MD5 | c13479ba5d061d95757dc0f965179f85 |
|
BLAKE2b-256 | fac55a7c1687b50149510c1b56ec719d57eb44326d7a0ae6726eb26c658ef7e8 |
Hashes for h3-3.7.3-cp35-cp35m-manylinux2010_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 7a0817ed9f6b8f4b7eeb719744260ab41ccd7131475b169e45a79cf99d045b1f |
|
MD5 | 904af0bc584124bec7b5f89dafd8cbb8 |
|
BLAKE2b-256 | 8133586c860b14b1070b60ddfdf8ed38ae9f65a285f92ab7c7efb2174a1591a3 |
Hashes for h3-3.7.3-cp35-cp35m-macosx_10_9_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 87c5ed2e2878cb936dd466ed5b4fc7cd462cc8a713d066789918d295d9d26a63 |
|
MD5 | 2b4169b5884fcd395663fa3dcccd50eb |
|
BLAKE2b-256 | 4ee9b506e5411a6bcae7d893e1a6f18758beb59a070c6c7952eefb118d0c02a2 |
Hashes for h3-3.7.3-cp27-cp27mu-manylinux2010_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 3909aef50b19835b0790e077d9f06b27609380bb7bf09382e2c4e813385f7677 |
|
MD5 | b19e0bda2bf7abb446564fc46c618173 |
|
BLAKE2b-256 | eb96d03c9dae15133d0aa525c8170ee505c8ad62cd864be780240547d385e3df |
Hashes for h3-3.7.3-cp27-cp27m-manylinux2010_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 105625a45d86b6cd1cd67acd7ab158adf3d193262534470b69a1db49a6664541 |
|
MD5 | 09c1c3904000ef55afdc3bb99b4cb29b |
|
BLAKE2b-256 | 33bd9a48a8689672dfd34c00c342960dac9af3b27eb1fae89ac899cd537c8a20 |
Hashes for h3-3.7.3-cp27-cp27m-macosx_10_9_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | ddbe4dd122be51508a43baee157a2724d52ec480b45da932f7ca058cfec4aaf9 |
|
MD5 | c42f989003678a6703a715708b21deef |
|
BLAKE2b-256 | a8794df054609bb3b638fddb8e9c9c9902e84475e38bcfae7f89697669b53ec1 |