克洛普斯地图没有显示我想要什么

2024-05-18 22:13:48 发布

您现在位置:Python中文网/ 问答频道 /正文

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

我得到的图像是这样的: enter image description here

但我需要这样的形象: enter image description here


Tags: namemapdfdatathresholdvaluecountnp
1条回答
网友
1楼 · 发布于 2024-05-18 22:13:48

问题在key_on='feature.properties.name'

应该是key_on='feature.properties.DISTRICT'

查看JSON文件,查看lat/long坐标映射到哪里。 在world map示例中,在JSON文件中它是'name',但是在san fransico它是'discritt'

# 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'

^{pr2}$

san fransico choropleth map

相关问题 更多 >

    热门问题