Giter Club home page Giter Club logo

h3-py's Introduction

H3-Python

Build Status H3 Version License

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

Installing

You need to have cc, make, and cmake in your $PATH when installing this package:

which cc
/usr/bin/cc
which make
/usr/bin/make
which cmake
/usr/bin/cmake

Python 3.5+:

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]

image

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

image

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

image

For more API reference, please see the H3 Documentation.

h3-py's People

Contributors

tenghu avatar isaacbrodsky avatar camelia-c avatar dfellis avatar krosaen avatar

Watchers

James Cloos avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.