Home > front end >  How to remove bold blue outline color from folium.Choropleth within an folium.featuregroup on the ma
How to remove bold blue outline color from folium.Choropleth within an folium.featuregroup on the ma

Time:05-25

I have the following geodataframe called results:

results info

Calling results.explore() will result in the following leaflet:

leaflet results

My idea is to create 4 different layers using Featuregroups and Choropleth wherein I want to see what type of influence depot location have on total amount of km's within each area. The variables I want to compare are: T*_depot_0, 2_depots, 3_depots, and 4_depots. I want to use the fill_color OrRd within each layer in order to distinguish high values with an darker red and lower values with lighter orange/yellow. By having layer control it would be able to click through the different Choropleth's and see the difference what different depots have on the total travel distance within each area.

My code:

def add_depot_markers_featuregroup(depot_amount, featuregroup): 
    for i in range(len(depots_locations)):
        if i > depot_amount:
            break
        folium.Marker(
                [depots_locations[i].y, depots_locations[i].x], 
                popup="Depot_{0}".format(i 1),
                icon=folium.Icon(color='cadetblue', icon='solid fa-bicycle', prefix='fa')).add_to(featuregroup)

result_map = folium.Map(location=lat_long_groningen, zoom_start=11, tiles=None)

layer_depot_1 = folium.FeatureGroup(name="1 depot", overlay=False).add_to(result_map)
layer_depot_2 = folium.FeatureGroup(name="2 depots", overlay=False).add_to(result_map)
layer_depot_3 = folium.FeatureGroup(name="3 depots", overlay=False).add_to(result_map)
layer_depot_4 = folium.FeatureGroup(name="4 depots", overlay=False).add_to(result_map)

fs=[layer_depot_1, layer_depot_2, layer_depot_3, layer_depot_4]
for i in range(len(fs)):
    add_depot_markers_featuregroup(i, fs[i])
    depot_column_name = ""
    if i == 0:  
        depot_column_name = "T*_depot_{0}".format(i) 
    else: 
        depot_column_name = "{0}_depots".format(i 1)
    
    bins = list(results[depot_column_name].quantile([0, 0.25, 0.5, 0.75, 1]))

    choropleth = folium.Choropleth(
        results, 
        data=results, 
        key_on='feature.properties.Postcode', 
        columns=["Postcode", depot_column_name], 
        fill_color="OrRd",
        fill_opacity = 0.8,
        line_opacity = 0,
        line_weight=1,
        bins=bins,
        legend_name = "T* per postalcode area based on depot {0}".format(i 1),
        name="T* of {0} depot per Postalcode area".format(i 1)).geojson.add_to(fs[i])
    
    geojson1 = folium.GeoJson(data=results, 
        name="tooltip "   depot_column_name,
        tooltip=folium.GeoJsonTooltip(fields=['Postcode', "Deliveries", "Area (km2)", "Number of cyclists", "Beardwood approx", depot_column_name], labels=True, sticky=True)
    ).add_to(choropleth)
   
# folium.TileLayer('cartodbdark_matter',overlay=True,name="dark mode").add_to(result_map)
folium.TileLayer('cartodbpositron',overlay=True, control=False, name="T*").add_to(result_map)
folium.LayerControl(collapsed=False).add_to(result_map)
result_map.save("lastmile.html")
result_map

So, the good news is the layers work. The bad news is that I have very bold blue lines between the different polygons and multigons on the map, which I don't know how to change/remove. I've tried setting the line_color="black" of the Choropleth, but that didn't work.

Current result

How to remove/change/minimize the bold blue outline colors within each featuregroup?

CodePudding user response:

Since no data is presented, I quote the enter image description here

  • Related