"blue is not a valid ColorBrewer code" 使用 Folium 创建 Choropleth 时出错 (Python)
"blue is not a valid ColorBrewer code" Error while creating Choropleth using Folium (Python)
我正在尝试使用 Folium 创建一个分区表,但是我 运行 出现了上述错误。
这是我的数据框:
这是 'MISSION' 地区的 GeoJSON 片段:
...{
"type": "Feature",
"properties": {
"OBJECTID": 4,
"DISTRICT": "MISSION",
"COMPANY": "D"
},
"geometry": {
"type": "Polygon",
"coordinates": [
[...
这是我创建等值线的尝试:
world_map.choropleth(
geo_data=world_geo,
name='choropleth',
data=dc,
columns=['Neighborhood', 'Count'],
key_on='feature.properties.DISTRICT',
# color='YlOrRd',
# fill_opacity=0.7,
# line_opacity=0.5
)
这是它抛出的错误:
---------------------------------------------------------------------------
ValueError Traceback (most recent call last)
<ipython-input-217-80d58334d627> in <module>
4 data=dc,
5 columns=['Neighborhood', 'Count'],
----> 6 key_on='feature.properties.DISTRICT',
7 # color='YlOrRd',
8 # fill_opacity=0.7,
/opt/conda/envs/Python36/lib/python3.6/site-packages/folium/folium.py in choropleth(self, *args, **kwargs)
416 )
417 from folium.features import Choropleth
--> 418 self.add_child(Choropleth(*args, **kwargs))
419
420 def keep_in_front(self, *args):
/opt/conda/envs/Python36/lib/python3.6/site-packages/folium/features.py in __init__(self, geo_data, data, columns, key_on, bins, fill_color, nan_fill_color, fill_opacity, nan_fill_opacity, line_color, line_weight, line_opacity, name, legend_name, overlay, control, show, topojson, smooth_factor, highlight, **kwargs)
1046 self._name = 'Choropleth'
1047
-> 1048 if data is not None and not color_brewer(fill_color):
1049 raise ValueError('Please pass a valid color brewer code to '
1050 'fill_local. See docstring for valid codes.')
/opt/conda/envs/Python36/lib/python3.6/site-packages/branca/utilities.py in color_brewer(color_code, n)
147
148 if base_code not in core_schemes:
--> 149 raise ValueError(base_code + ' is not a valid ColorBrewer code')
150
151 try:
ValueError: blue is not a valid ColorBrewer code
请帮帮我。
如您所见,base codes, but the default param for fill_color
in folium.features.Choropleth 中没有 blue
是 'blue'。
尝试在创建等值线时通过添加 fill_color = "Blues"
参数将其更改为类似 Blues
的内容,并查看是否有变化
我正在尝试使用 Folium 创建一个分区表,但是我 运行 出现了上述错误。 这是我的数据框:
这是 'MISSION' 地区的 GeoJSON 片段:
...{
"type": "Feature",
"properties": {
"OBJECTID": 4,
"DISTRICT": "MISSION",
"COMPANY": "D"
},
"geometry": {
"type": "Polygon",
"coordinates": [
[...
这是我创建等值线的尝试:
world_map.choropleth(
geo_data=world_geo,
name='choropleth',
data=dc,
columns=['Neighborhood', 'Count'],
key_on='feature.properties.DISTRICT',
# color='YlOrRd',
# fill_opacity=0.7,
# line_opacity=0.5
)
这是它抛出的错误:
---------------------------------------------------------------------------
ValueError Traceback (most recent call last)
<ipython-input-217-80d58334d627> in <module>
4 data=dc,
5 columns=['Neighborhood', 'Count'],
----> 6 key_on='feature.properties.DISTRICT',
7 # color='YlOrRd',
8 # fill_opacity=0.7,
/opt/conda/envs/Python36/lib/python3.6/site-packages/folium/folium.py in choropleth(self, *args, **kwargs)
416 )
417 from folium.features import Choropleth
--> 418 self.add_child(Choropleth(*args, **kwargs))
419
420 def keep_in_front(self, *args):
/opt/conda/envs/Python36/lib/python3.6/site-packages/folium/features.py in __init__(self, geo_data, data, columns, key_on, bins, fill_color, nan_fill_color, fill_opacity, nan_fill_opacity, line_color, line_weight, line_opacity, name, legend_name, overlay, control, show, topojson, smooth_factor, highlight, **kwargs)
1046 self._name = 'Choropleth'
1047
-> 1048 if data is not None and not color_brewer(fill_color):
1049 raise ValueError('Please pass a valid color brewer code to '
1050 'fill_local. See docstring for valid codes.')
/opt/conda/envs/Python36/lib/python3.6/site-packages/branca/utilities.py in color_brewer(color_code, n)
147
148 if base_code not in core_schemes:
--> 149 raise ValueError(base_code + ' is not a valid ColorBrewer code')
150
151 try:
ValueError: blue is not a valid ColorBrewer code
请帮帮我。
如您所见,base codes, but the default param for fill_color
in folium.features.Choropleth 中没有 blue
是 'blue'。
尝试在创建等值线时通过添加 fill_color = "Blues"
参数将其更改为类似 Blues
的内容,并查看是否有变化