如何从叶面中删除叶片中的大胆蓝色轮廓颜色。

发布于 2025-01-31 21:55:58 字数 3049 浏览 3 评论 0原文

我有以下geodataframe称为结果:

​。

​以及我想查看库库的位置对每个区域内的km总数有哪种类型的影响力。我要比较的变量是:t*_depot_02_depots3_depots4_depots。我想在每一层中使用fill_color orrd,以区分较深的红色和较低值的高值,较轻的橙色/黄色。通过具有图层控制,它将能够单击不同的绒毛膜,并查看每个区域内的总旅行距离上不同的仓库的区别。

我的代码:

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

好消息是层正在起作用。坏消息是,我在地图上的不同多边形和多数基因之间有非常大胆的蓝线,我不知道该如何更改/删除。我已经尝试设置Choropleth的line_color =“ Black”,但这无效。

如何删除/更改/最小化每个功能组中的大胆蓝色轮廓颜色?

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?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

暖阳 2025-02-07 21:55:58

由于没有显示数据,因此我引用。多边形轮廓的线装饰由样式函数定义。样品定义了颜色,线宽度和虚线。线宽是由“重量”设置的。

import json
import requests
import folium

url = ("https://raw.githubusercontent.com/python-visualization/folium/main/examples/data")
us_states = f"{url}/us-states.json"

geo_json_data = json.loads(requests.get(us_states).text)

m = folium.Map([43, -100], zoom_start=4)

folium.GeoJson(
    geo_json_data,
    style_function=lambda feature: {
        "fillColor": "#ffff00",
        "color": "black",
        "weight": 2,
        "dashArray": "5, 5",
    },
).add_to(m)

m

Since no data is presented, I quote the official sample. The line decoration of the polygon's outline is defined by the style function. The sample defines color, line width, and dashed lines. Line width is set by 'weight'.

import json
import requests
import folium

url = ("https://raw.githubusercontent.com/python-visualization/folium/main/examples/data")
us_states = f"{url}/us-states.json"

geo_json_data = json.loads(requests.get(us_states).text)

m = folium.Map([43, -100], zoom_start=4)

folium.GeoJson(
    geo_json_data,
    style_function=lambda feature: {
        "fillColor": "#ffff00",
        "color": "black",
        "weight": 2,
        "dashArray": "5, 5",
    },
).add_to(m)

m

enter image description here

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文