Folium Choropleth map - How can I fill gaps in map with surrounding color?

Viewed 151

I'm trying to create a choropleth map by 3-digit zip code with caterogies defined from 2 to 8. I found a shape file on this link zip3 shape file, and I converted it to geojson using map shaper. My data has zip3 and a category for each zip3. There aren't any na's in my data, but the resulting map doesn't color all zips, some of them show as nan. I don't know if it's the json file, but I'm just trying to fill those na's with the color of the category that would correspond to them.

Here's my code:

zip3_json = 'zip3.json'

categories = pd.read_excel('categories.xlsx', header = 1,
                                     dtype = {'ZIP3': str}) 
            
map_us = folium.Map(location = [38, -92], zoom_start = 4.4)
        
folium.Choropleth(geo_data = zip3_json, data = categories, columns = ['ZIP3', 'CATEGORY'], 
                              key_on = 'feature.properties.ZIP3',
                             fill_color = 'Spectral', bins = [2,3,4,5,6,7,8,9], fill_opacity = 0.7, line_opacity = 0.2, legend_name = 'Category', line_weight = 0.1, highlight = True).add_to(map_us)
        
map_us

Choropleth map category by zip3

0 Answers
Related