Carlie
Carlie

Reputation: 1

Chloropleth map does not yet any output

The Geojson file is available: The following code does not display any outcome, what's the issue?

!wget --quiet https://cocl.us/sanfran_geojson -O san_francisco_nh.json

print('GeoJSON file downloaded!')
sanfran_map.choropleth(
    geo_data=sanfran_geo,
    data=df_sf,
    columns=['Neighborhood', 'Count'],
    key_on='feature.properties.DISTRICT',
    fill_color='YlOrRd', 
    fill_opacity=0.7, 
    line_opacity=0.2,
    legend_name="Crime Rate in San Francisco"
)

Upvotes: 0

Views: 51

Answers (1)

sentence
sentence

Reputation: 8903

Use folium.Choropleth and folium.LayerControl:

import folium

m = folium.Map(location=[37.773972, -122.43],
               zoom_start=10,
               control_scale=True)

folium.Choropleth(geo_data=sanfran_geo,
                  name='choropleth',
                  data=df_sf,
                  columns=['Neighborhood', 'Count'],
                  key_on='feature.properties.DISTRICT',
                  fill_color='YlOrRd',
                  fill_opacity=0.7,
                  line_opacity=0.2,
                  legend_name='Crime Rate in San Francisco').add_to(m)

folium.LayerControl().add_to(m)

m

Upvotes: 1

Related Questions