I'm using Folium to generate a revenue report by zip code, to determine where to establish a new office.
While it seems like the geoJSOn is properly overlaying on the map, it doesn't seem to be heat-mapping the revenue amounts to their respective ZIP codes.
The feature name in the JSON file is feature.properties.ZCTA5CE10
As seen here, in the first few lines of the file. ZCTA5CE10 corresponds with the Zipcode. Here is a link to the GeoJSON file on GitHub. https://github.com/OpenDataDE/State-zip-code-GeoJSON/blob/master/tx_texas_zip_codes_geo.min.json
{"type":"FeatureCollection",
"features":[{
"type":"Feature",
"properties":
{"STATEFP10":"48","ZCTA5CE10":"75801","GEOID10":"4875801","CLASSFP10":"B5","MTFCC10":"G6350","FUNCSTAT10":"S","ALAND10":555807428,"AWATER10":6484251,"INTPTLAT10":"+31.7345202","INTPTLON10":"-095.5313809","PARTFLG10":"N"},"geometry":{"type":"Polygon","coordinates":[[[-95.680719,31.727999]
My Revenue data is a CSV file with 2 columns, ZIP CODE and AUGUST.
Example CSV:
ZCTA5CE10,AUGUST
"76701",2676.89
"76643",8625.79
"76655",5618
"76710",23265.18
"76708",14618.35
"76706",14335.85
"76705",9338.44
"76633",4215.39
"76712",35488.02
"76657",10186.13
"76664",1361
"76711",2812.35
"76682",713
And finally, my code.
import folium
from folium.plugins import MarkerCluster
import pandas as pd
import os
map = folium.Map(location=[31.5493, -97.1467],
default_zoom_start=15)
revdata = pd.read_csv(os.path.join('revenue.csv'))
revdata.info()
folium.Choropleth(geo_data="tx_texas_zip_codes_geo.min.json",
data = revdata,
columns = ['ZIP CODE', 'AUGUST'],
key_on = 'feature.properties.ZCTA5CE10',
fill_color='BuPu', fill_opacity=0.7, line_opacity = 0.2,
legend_name = 'REVENUE BY ZIP').add_to(map)
marker_cluster = MarkerCluster().add_to(map)
map.save('mymap.html')
I've tried changing the zip codes in my CSV file to have quotes around them, but that doesn't change anything.
Ideas?