Reputation: 1
threshold_scale = np.linspace(df_value_counts['Count'].min(),
df_value_counts['Count'].max(),
6, dtype=int)
threshold_scale = threshold_scale.tolist()
threshold_scale[-1] = threshold_scale[-1] + 1
sf_map.choropleth(
geo_data=sf_geo,
data=df_value_counts,
columns=['Neighborhood', 'Count'],
key_on='feature.properties.name',
fill_color='YlOrRd',
fill_opacity=0.7,
line_opacity=0.2,
threshold_scale=threshold_scale,
legend_name='Crime Rate in San Francisco')
sf_map
but I need to have an image like this:
Upvotes: 0
Views: 1029
Reputation: 21
the issue is in key_on='feature.properties.name'
should be key_on='feature.properties.DISTRICT'
look at the JSON file and see where the lat/long coordinates are mapped to. In the world map example, in its JSON file it was 'name' but in san fransico it is 'DISCTRICT'
# download countries geojson file
!wget --quiet https://cocl.us/sanfran_geojson -O san_francisco_nh.json
print('GeoJSON file downloaded!')
sf_geo = r'san_francisco_nh.json'
sanfran_map.choropleth(
geo_data=sf_geo,
data=nh_countindex,
columns=['Neighborhood','Count'],
key_on='feature.properties.DISTRICT',
fill_color='YlOrRd',
fill_opacity=0.7,
line_opacity=0.2,
legend_name="Neighborhood Crime"
)
sanfran_map
Upvotes: 1