首页 > 解决方案 > 如何设置geojson的样式?

问题描述

我的输入是一个 shapefile,我正在尝试根据不同的 Traveltime 保存我的数据的颜色代码。

我可以传递数据并保存为 html,但它似乎没有为我的数据着色。

gjson=isochrone.to_crs(epsg='4326').to_json()
iso=json.loads(gjson)
      
map_Baseline=folium.Map(location=[52.486044, -1.892751],zoom_start=12)

folium.GeoJson(iso,
               name='geojson',
               style_function= lambda x :{
                   'fillcolor': (
                     'green' if  x['properties']['Traveltime'] == '10800'
                     else 'orange' if '7800' == x['properties']['Traveltime'] == '5400' 
                     else 'red'},
           ).add_to(map_Baseline)

folium.LayerControl(iso).add_to(map_Baseline)
map_Baseline.save("map.html")

有任何想法吗?谢谢

标签: pythongeojson

解决方案


推荐阅读