Last active
April 22, 2022 14:53
-
-
Save kidpixo/353eca9752a6587156fa109f93a3b6c3 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# tested using https://github.com/uber/h3-py-notebooks/blob/master/notebooks/usage.ipynb | |
from h3 import h3 | |
from shapely.geometry.polygon import Polygon | |
h3_list = [ Polygon(h3.h3_to_geo_boundary(he)) for he in h3.hex_ring(h,2)] | |
n = len(h3_list) | |
print(f'Polygon.exterior.is_closed = {h3_list[0].exterior.is_closed}') | |
import geopandas as gpd | |
gdf=gpd.GeoDataFrame(columns=['value'],data=range(len(h3_list)),geometry=h3_list) | |
import matplotlib.cm as cm | |
gdf['color_rgba'] = gdf.apply(lambda row: cm.Spectral(row['value']/n), axis=1) | |
gdf.plot(color=gdf['color_rgba']) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment