Reputation: 72
I am plotting polygon map of a city district and set colormap base on area, I would like to set background tile as OpenStreetMap. but the result is that, with many details and colors of the OpenStreetMap, I feel quite fussy about how it looks.
import geopandas as gpd
df_polygon = gpd.read_file(path)
import folium
m=df_polygon.explore(column='AREA_BMA'
,tooltip={"SUBDISTR_1"}
,popup=True
,cmap='Greens'
,legend=False
,style_kwds=dict(color="black",weight=1, opacity=0.4)
,name="Polygon")
folium.LayerControl().add_to(m)
m
I have tried using ...
opacity=0.7
min_opacity=0.7
fillOpacity=0.7
alpha=0.7
but got Error: unexpected keyword argument.
and also tried to set opacity of openstreetmap, but this is not what I wanted.
folium.TileLayer('openstreetmap', control=True, opacity=0.3,name="openstreetmap opacity 0.3").add_to(m)
folium.LayerControl().add_to(m)
Would anybody know a way to set the opacity of colormap?
Upvotes: 2
Views: 2463
Reputation: 7814
You need to pass fillOpacity
within style_kwds
.
m=df_polygon.explore(column='AREA_BMA',
tooltip={"SUBDISTR_1"},
popup=True,
cmap='Greens',
legend=False,
style_kwds=dict(color="black",weight=1, opacity=0.4, fillOpacity=.7),
name="Polygon"),
Upvotes: 5