ValueError: blue is not a valid ColorBrewer code
See original GitHub issuePlease add a code sample or a nbviewer link, copy-pastable if possible
# Your code here
def my_colors(feature):
"""Postcodes will be colored based on the drive time assigned to """
def my_colors(feature):
"""Postcodes will be colored based on the drive time assigned to """
if drive_time[feature['drv_tm']] == 30:
return #1b9e77
if drive_time[feature['drv_tm']] == 45:
return #d95f02
if drive_time[feature['drv_tm']] == 60:
return #7570b3
if drive_time[feature['drv_tm']] == 75:
return #e7298a
if drive_time[feature['drv_tm']] == 90:
return #66a61e
if drive_time[feature['drv_tm']] == 120:
return #e6ab02
else:
return #a6761d
style_function=lambda feature:{
'fillColor': my_colors(feature)
,'color': 'black'
,'weight': 2
}
style_function=lambda feature:{
'fillColor': my_colors(feature)
,'color': 'black'
,'weight': 2
}
layer= folium.features.Choropleth(
geo_data= gjson_dt # gjson_dt, is the geojson feature object created from the geodataframe
,data=drive_time #dataframe that contain the postgres table related to the geojson file
,style_function= style_function
,name= 'drv_time' # name of the layer
,key_on='feature.properties.postcode' # Feature ID of the dataframe in this case 'postcode'
,columns= ['postcode', 'drv_tm']# column to use for the choropleth
,highlight=True # highlight the polygon and zoom in to it when you click on the polygon
,legend_name='Drive Time' # legend name
m.add_child(layer)
Problem description
I’m trying to display a thematic map with folium using values from a column and a function (color ramp) but I’m getting ValueError: blue is not a valid ColorBrewer code as result.
[this should explain why the current behavior is a problem and what is the expected output.]
Expected Output
I’m expecting to get a map with specific color based on a column [‘drv_tm’] values and function that contain the color ramp
Output of folium.__version__
0.8.3
Issue Analytics
- State:
- Created 4 years ago
- Comments:8 (3 by maintainers)
Top Results From Across the Web
"blue is not a valid ColorBrewer code" Error while creating ...
As you can see there is no blue in the base codes, but the default param for fill_color in folium.features.Choropleth is 'blue'.
Read more >Choropleth maps Classwork, Seminar 4, MHC, CUNY, Spring ...
If we set it to "Blue": we get the error: ... in choropleth raise ValueError('Please pass a valid color brewer code to '...
Read more >GeoJSON and Choropleth maps lab, Spring 2017
5/site-packages/folium/folium.py", line 601, in choropleth raise ValueError('Please pass a valid color brewer code to ' ValueError: Please pass a valid color ...
Read more >branca.utilities.color_brewer Example - Program Talk
python code examples for branca.utilities.color_brewer. ... raise ValueError('Please pass a valid color brewer code to ' 'fill_local.
Read more >Source code for proplot.styletools
*No*. Try using @timer on # register functions, turns out worst is colormap one at 0.1 seconds. ... 3: raise ValueError(f'Invalid RGB argument...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
@Gustacro can you place here all the output error? I think that what is creating your error is the Choropleth default value of fill_color=blue.
From Choropleth docstring:
But in fact, currently, only the brewer palettes codes are working. Passing a color hex code gives the same error.
Pretty sure the original issue has been solved by https://github.com/python-visualization/folium/pull/1288