question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Choropleth map not displaying colors

See original GitHub issue

I am trying to make a choropleth map using data stored in a ‘.csv’ over a '.geojson’ polygon map. The geojson map is apparently rendering properly, but the colors from the values in the data.csv aren’t showing up at all. I am new using folium and after reading the whole documentation I can’t still figure out what I am doing wrong! I have posted the jupyter notebook and all data in a github repository.

I am working in a conda environment using folium ‘0.5.0’

Thanks in advance!

https://github.com/transluciddata/folium_problem

https://nbviewer.jupyter.org/github/transluciddata/folium_problem/blob/master/prueba.ipynb

import pandas as pd
import folium
import json
import os

regiones_data = os.path.join('regiones.csv')
regiones_geo = os.path.join('regiones.geojson')

data = pd.read_csv(regiones_data, na_values=[' '])

data.info()

m = folium.Map(
    location=[-37.807973, -71.894346], 
    tiles='Mapbox Bright',
    zoom_start=4,
    control_scale=True
)

m.choropleth(
    geo_data=regiones_geo,
    name='choropleth',
    data=data,
    columns=['region_id', 'votos_tricel'],
    key_on='feature.properties.region_id',
    fill_color='BuPu',
    fill_opacity=.7,
    line_opacity=.5,
    highlight=True,
    legend_name='Numero Total de Votos',
    reset=True
)

folium.LayerControl().add_to(m)

m

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:8

github_iconTop GitHub Comments

15reactions
Conengmocommented, Jul 22, 2018

The problem is with the region_ids in your geojson. Their values are strings, but in the csv they are ints. If you change the values in the geojson to ints it works:

"region_id": "2"

becomes

"region_id": 2

8reactions
sergiolucerocommented, Jul 22, 2018

you’re not adding the choropleth to the map

On Sun, Jul 22, 2018, 12:09 Mauricio Cifuentes Navarro < notifications@github.com> wrote:

I am trying to make a choropleth map using data stored in a ‘.csv’ over a '.geojson’ polygon map. The geojson map is apparently rendering properly, but the colors from the values in the data.csv aren’t showing up at all. I am new using folium and after reading the whole documentation I can’t still figure out what I am doing wrong! I have posted the jupyter notebook and all data in a github repository.

I am working in a conda environment using folium ‘0.5.0’

Thanks in advance! https://github.com/transluciddata/folium_problem https://nbviewer.jupyter.org/github/transluciddata/folium_problem/blob/master/prueba.ipynb

import pandas as pdimport foliumimport jsonimport os

regiones_data = os.path.join(‘regiones.csv’) regiones_geo = os.path.join(‘regiones.geojson’)

data = pd.read_csv(regiones_data, na_values=[’ ']) data.info()

m = folium.Map( location=[-37.807973, -71.894346], tiles=‘Mapbox Bright’, zoom_start=4, control_scale=True )

m.choropleth( geo_data=regiones_geo, name=‘choropleth’, data=data, columns=[‘region_id’, ‘votos_tricel’], key_on=‘feature.properties.region_id’, fill_color=‘BuPu’, fill_opacity=.7, line_opacity=.5, highlight=True, legend_name=‘Numero Total de Votos’, reset=True )

folium.LayerControl().add_to(m)

m

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/python-visualization/folium/issues/917, or mute the thread https://github.com/notifications/unsubscribe-auth/AGzdufIVjD2d0uwiDvnORx_MUJ2HM53Eks5uJKOegaJpZM4VaDPG .

Read more comments on GitHub >

github_iconTop Results From Across the Web

Choropleth map is not showing color variation in the output
Choropleth map is not showing color variation in the output ; from pandas import ; import os import ; False) vis = os.path.join('Community_Areas....
Read more >
Filled map (choropleth) data colors not working
Solved: I'm working on trying to create shading (color scale) on a Filled Map. Following the instructions on.
Read more >
Colors not displaying on Plotly Choropleth Map in iPython ...
Hello I recently downloaded and installed plotly in order to create a Choropleth U.S. map of Zika cases in the iPython notebook.
Read more >
Choropleth map not displaying color-Pandas,Python
[Solved]-Data visualization: Choropleth map not displaying color-Pandas,Python ... We need to link the country abbreviation name to GeoJson's ISO_A3. from urllib.
Read more >
Design Choropleth Colors & Intervals
Good choropleth maps make true and insightful geographic patterns clearly visible to readers, whether they are printed in black-and-white on paper or displayed...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found