uber h3 folium 绘制 可视化 - xd21303/Notebook GitHub Wiki
安装
pip install h3
conda install h3-py -c conda-forge
import folium
from folium.features import DivIcon
from folium import plugins
from h3 import h3
# 编码,纬度在前,经度在后
h3.geo_to_h3(31.719334, 120.01532,12)
# 解码
h3.h3_to_geo('85411d4bfffffff')
# 获取边界
h3.h3_to_geo_boundary('85411d4bfffffff')
# folium 绘制
folium.Polygon(h3.h3_to_geo_boundary('85411d4bfffffff'))
map_gaode = folium.Map(
tiles=
'http://wprd02.is.autonavi.com/appmaptile?lang=zh_cn&size=1&scale=1&style=7&scl=1&x={x}&y={y}&z={z}',
attr='default')
h = h3.geo_to_h3(lat, lon, 10)
rec = h3.h3_to_geo_boundary(h)
folium.Polygon(rec, weight=2, # 线条宽度
color='red').add_to(map_gaode)
map_gaode.fit_bounds(map_gaode.get_bounds())
map_gaode