1

I´m trying to plot some h3 hexagons with folium using .explore

Here is my code:

B['h3_code'] = B.apply(lambda row: h3.geo_to_h3(row['latitude_Destino'], row['longitude_Destino'], 8), axis=1)

desthex = B.groupby('h3_code').size().to_frame("Dest").reset_index()


def h3pol(h3_id):
    return Polygon(h3.h3_to_geo_boundary(h3_id, geo_json=True))


desthex["geometry"] = desthex["h3_code"].apply(lambda x: h3pol(x))

desthex = gpd.GeoDataFrame(desthex, geometry=desthex["geometry"], crs='EPSG:4326').to_crs("4326")
desthex = desthex[["geometry", "Dest", "h3_code"]]


m6 = folium.Map([-31.63238910, -60.69945910], tiles="OpenStreetMap", zoom_start=14)

desthex.explore(column="Dest",scheme="EqualInterval",k=10,cmap='Greens', highlight = True, legend = False, popup = True, legend_kwds={'interval': 'True'}).add_to(m6)


loc = "Atractores"
title_html = '''
                <h3 align="center" style="font-size:16px"><b>{}</b></h3>
               '''.format(loc)
m6.get_root().html.add_child(folium.Element(title_html))
m6.save("Output/atractoreshex.html")

The problem is that the map isn`t showing any hexagon at all.

FG85
  • 41
  • 4

0 Answers0