from h3 import h3 from shapely.geometry import Polygon,mapping def dict_to_shapely(d): coords = d['features'][0]['geometry']['coordinates'][0] return Polygon(coords) def polygon_to_h3(polygon,resolution): polygon = mapping(polygon) hexas = h3.polyfill(polygon,res=resolution,geo_json_conformant=True) return list(set(hexas)) #read geojson file with open("sample-bbx.geojson",'r') as f: polygon_dict = json.loads(f.read()) shapely_polygon = dict_to_shapely(polygon_dict) f.close() h3_idx = polygon_to_h3(shapely_polygon,resolution=8) h3_idx = pd.DataFrame(pd.Series(h3_idx,name='h3'))