Skip to main content

Python bindings for H3, a hierarchical hexagonal geospatial indexing system developed by Uber Technologies

Project description

H3-Python

Build Status License

This library provides Python bindings for the H3 Core Library. For API reference, please see the H3 Documentation.

Installing

You need to have a cc in your $PATH when installing this package:

which cc
/usr/bin/cc

Python 3.4+:

pip install h3

Development

git clone https://github.com/uber/h3-py.git && cd h3-py
virtualenv env
source env/bin/activate
pip install -r requirements-dev.txt
fab bootstrap

Usage

The following visualizations are achieved with folium.

from h3 import h3

Convert lat/lng to hexagon address

h3_address = h3.geo_to_h3(37.3615593, -122.0553238, 5) # lat, lng, hex resolution
hex_center_coordinates = h3.h3_to_geo(h3_address) # array of [lat, lng]
hex_boundary = h3.h3_to_geo_boundary(h3_address) # array of arrays of [lat, lng]

Get KRings of hexagon

h3.k_ring_distances(h3_address, 4) # array of 4 rings with size [1, 6, 12, 18]
h3.k_ring(h3_address, 4) # a collection of hexagons within kring sizes from 0 to 3

Polyfill a Geo Json with hexagons

geoJson = {'type': 'Polygon',
 'coordinates': [[[37.813318999983238, -122.4089866999972145],
 [ 37.7866302000007224, -122.3805436999997056 ],
 [37.7198061999978478, -122.3544736999993603],
 [ 37.7076131999975672, -122.5123436999983966 ],
 [37.7835871999971715, -122.5247187000021967],
 [37.8151571999998453, -122.4798767000009008]]] }
hexagons = list(h3.polyfill(geoJson, 8)) # resolution 8

For more API reference, please see the H3 Documentation.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

h3-2.9.tar.gz (8.9 kB view details)

Uploaded Source

File details

Details for the file h3-2.9.tar.gz.

File metadata

  • Download URL: h3-2.9.tar.gz
  • Upload date:
  • Size: 8.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.11.0 pkginfo/1.4.2 requests/2.19.1 setuptools/40.0.0 requests-toolbelt/0.8.0 tqdm/4.24.0 CPython/3.6.4

File hashes

Hashes for h3-2.9.tar.gz
Algorithm Hash digest
SHA256 f4c98f8110c96fe50983aef50999f213664e0d4f7aa55291a839baa0312c5ca4
MD5 35b9feb289038bc7b0dad60b8f47c94a
BLAKE2b-256 f071d95c0470b084f5c74bf2e5840b3adac521d7173bc9262a2c4b23c60d917a

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page