我有一个关于大叶中的Choropleth函数的问题。
state_data = pd.read_csv('data.csv')
mssp = folium.Map()
folium.Choropleth(
geo_data='geodata.geojson',
name='choropleth',
data=state_data,
columns=['District', 'Rooms'],
key_on='feature.id',
fill_color='YlGn',
fill_opacity=0.7,
line_opacity=0.2,
legend_name='Rooms'
).add_to(mssp)
folium.LayerControl().add_to(mssp)
mssp
我的CSV:
Price,Condo,Size,Rooms,Toilets,Suites,Parking,Elevator,Furnished,SwimmingPool,New,District,NegotiationType,PropertyType,Latitude,Longitude
930,220,47,2,2,1,1,0,0,0,0,Artur Alvim,rent,apartment,-23.543138,-46.479486
我的GeoJSON:
{
"type": "GeometryCollection",
"geometries": [{
"type": "MultiPolygon",
"id": "Artur Alvim",
"coordinates": [
[
[
[-46.501092999999997, -23.545874999999999],
[-46.501199999999997, -23.545991999999998],
[-46.501261, -23.546139],
[-46.502249999999997, -23.54945]
]
]
]
}
]
}
我尝试了几种不同的'key_on'值,但是没有任何效果。它只是绘制区(为便于阅读,我在GeoJSON中省略了一些坐标,但这没关系)和图例。
[如果有人能提供帮助,尤其是向我解释这一点,我将不胜感激。
[How the output currently looks(在价格列中选中价格,但客房也不起作用)]
另外感谢!
从以下位置修改key_on
参数:
key_on=feature.id
到
key_on=feature.geometries.id
[id
在geometries
下,因此您也应该放在这里。