Skip to content

Choropleth Map - Folium Data Won't Show #1366

@grantbriana

Description

@grantbriana
# Your code here
import folium
import pandas as pd

address = 'Columbus, GA'

geolocator = Nominatim(user_agent="ga_explorer")
location = geolocator.geocode(address)
latitude = location.latitude
longitude = location.longitude
print('The geograpical coordinate of Columbus, GA are {}, {}.'.format(latitude, longitude))


df = pd.read_csv(r'C:\Users\Jill\Downloads\Income__by_Zip_Code__2018_River_valley.csv', usecols=('PlanningRegion','GEOID','aMeanHHIncome_e18','TotPop_e18'), encoding='utf-8')
zip_data = "https://opendata.arcgis.com/datasets/c917469836c2472e9b80ec0b57a24468_111.geojson?where=PlanningRegion%20%3D%20'River%20Valley'%20AND%20%20(GEOID%20%3D%20'31820'%20OR%20GEOID%20%3D%20'31901'%20OR%20GEOID%20%3D%20'31903'%20OR%20GEOID%20%3D%20'31904'%20OR%20GEOID%20%3D%20'31906'%20OR%20GEOID%20%3D%20'31907'%20OR%20GEOID%20%3D%20'31909')%20"
df=df.drop([0,1,2,3,4,5,7,8,9,10,12,13,14,19,20,21,22,23,24,25,26,27,28,30])

map_columbus = folium.Map(location=[latitude, longitude], zoom_start=10)

map_columbus.choropleth(
    geo_data=zip_data,
    data=df,
    columns=['GEOID','aMeanHHIncome_e18'],
    key_on='feature.properties.id',
    fill_color='YlGnBu', 
    fill_opacity=1, 
    line_opacity=1,
    legend_name='Average Household Income',
    smooth_factor=0)

folium.LayerControl().add_to(map_columbus)
# display map
map_columbus

Problem description

I'm experiencing an issue while creating a folium choropleth map in jupyter notebook. Everything is showing as expected except the data that should be in the map. Instead, the geodata is left blank, not filled with color.

pasted image 0

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions