Prerequisites:
A partir de Python 3.5
$ pip install h3
from h3 import h3
h3_address = h3.geo_to_h3( 47.3615593, -3.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]
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
geoJson = {'type': 'Polygon',
'coordinates': [[
[47.813318999983238, -3.4089866999972145],
[ 47.7866302000007224, -3.3805436999997056 ],
[47.7198061999978478, -3.3544736999993603],
[ 47.7076131999975672, -3.5123436999983966 ],
[47.7835871999971715, -3.5247187000021967],
[47.8151571999998453, -3.4798767000009008]]] }
hexagons = list(h3.polyfill(geoJson, 8)) # resolution 8
Sur OSX, erreur lors de l’installation https://github.com/uber/h3-py/issues/5
which make
which cc
which cmake
Si pas de path pour cmake,
echo $PATH
Si /usr/local/bin n’est pas présent, le rajouter par la commande suivante
export PATH="/usr/local/bin:$PATH"
ou il faut installer cmake.
brew install cmake
git clone https://github.com/uber/h3-py.git
cd h3-py
./install.sh