我使用来自kaggle的开放数据集的folium库,
map.choropleth(geo_path=country_geo, data=plot_data,
columns=['CountryCode', 'Value'],
key_on='feature.id',
fill_color='YlGnBu', fill_opacity=0.7, line_opacity=0.2,
legend_name=hist_indicator
)上面的代码部分给出了以下错误:
TypeError: choropleth() got an unexpected keyword argument 'geo_path'当我用geo_data替换geo_path时,我得到这个错误:
JSONDecodeError: Expecting value: line 7 column 1 (char 6)发布于 2017-12-10 06:16:18
这个问题与"UCSanDiegoX: DSE200x数据科学的Python“有关吗?我采纳了科迪的建议,按照map.choropleth的规范将geo_path重命名为geo_data。在git hub存储库中,请注意使用原始数据,它实际上是一个采用GeoJSON格式结构化的文件。前两行的开头应该与下面提供的代码类似
{"type":"FeatureCollection","features":[
{"type":"Feature","properties":{"name":"Afghanistan"},"geometry":
{"type":"Polygon","coordinates":[[[61.210817,35.650072],.....发布于 2017-10-27 00:22:37
geo_path不起作用,因为它不是choropleth的参数。您用geo_data替换它是正确的。
您的第二个错误可能是因为geojson文件不存在或格式不正确。
在http://python-visualization.github.io/folium/docs-master/modules.html?highlight=chor#中,geo_data的参数必须是“GeoJSON几何图形的URL、文件路径或数据(json、dict、geopandas等)”。
Geojson.org中的GeoJSON格式文件遵循以下结构:
{
"type": "Feature",
"geometry": {
"type": "Point",
"coordinates": [125.6, 10.1]
},
"properties": {
"name": "Dinagat Islands"
}
}https://stackoverflow.com/questions/46717177
复制相似问题