[Python] "blue is not a valid ColorBrewer code" Error while creating Choropleth using Folium...

Discussão em 'Python' iniciado por Stack, Agosto 5, 2025.

  1. Stack

    Stack Membro Participativo

    I am trying to create a choropleth using Folium, however I am running to the error mentioned above. Here is my dataframe:

    [​IMG]

    Here is my GeoJSON snippet for 'MISSION' district:

    ...{
    "type": "Feature",
    "properties": {
    "OBJECTID": 4,
    "DISTRICT": "MISSION",
    "COMPANY": "D"
    },
    "geometry": {
    "type": "Polygon",
    "coordinates": [
    [...


    Here is my attempt at creating the choropleth:

    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
    )


    Here is the error that it throws:

    ---------------------------------------------------------------------------
    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


    Please help me out.

    Continue reading...

Compartilhe esta Página