繁体   English   中英

没有得到正确的 map 颜色代码

[英]Not getting the right map color codes

在我的原始帖子中,我在尝试创建 map 时遇到错误,但我想我设法通过了。 我确定我没有选择正确的key_on功能,但不确定为什么它不会显示正确的图像。 请帮忙! 我从这里得到我的文件http://adamw523.com/toronto-geojson/

我希望能得到这样的东西。

旧金山的犯罪率

这是我尝试过的

df_crime=pd.DataFrame(df.Neighbourhood)
df_crime['premisetype']=pd.DataFrame(df.premisetype)
df_crime['offence']=pd.DataFrame(df.offence)
df_crime['MCI']=pd.DataFrame(df.MCI) #major crime indicators e.g. Theft
df_crime['occurrencedate']=pd.DataFrame(df.occurrencedate)
df_crime['reporteddate']=pd.DataFrame(df.reporteddate)
df_crime['occurrencehour'] = df_crime.occurrencedate.dt.strftime('%H:%M')
df_crime['reportedyear'] = df_crime.reporteddate.dt.strftime('%Y')
df_crime['reportedmonth'] = df_crime.reporteddate.dt.strftime('%m')
df_crime['reportedday'] = df_crime.reporteddate.dt.strftime('%d')
df_crime['reportedhour'] = df_crime.reporteddate.dt.strftime('%H:%M')
df_crime['Lat']=pd.DataFrame(df.Lat)
df_crime['Long']=pd.DataFrame(df.Long)
df_crime.head()

我使用的坐标是:

TORONTO_LAT = 43.70011 TORONTO_LONG = -79.4163

我也有这个代码给我计数

df_crime1=df_crime.groupby('Neighbourhood').size().reset_index(name="Count")
world_geo = r'simple.geojson' # geojson file
# create map of Toronto using latitude and longitude values
map_toronto = folium.Map(location=[TORONTO_LAT,TORONTO_LONG ], zoom_start=10)

folium.Choropleth(geo_data=world_geo,
                  data=df_crime1, 
                  columns=['Neighbourhood', 'Count'],
                  key_on='feature.properties.DAUID',
                  fill_color='YlOrRd',
                  fill_opacity=0.7,
                  line_opacity=0.2,
                  legend_name='Crime Rate in Toronto'
                  ).add_to(map_toronto)

map_toronto

这是我得到的图像

多伦多犯罪率

在我的原始帖子中,我在尝试创建 map 时遇到错误,但我想我设法通过了。 我确定我没有选择正确的key_on功能,但不确定为什么它不会显示正确的图像。 请帮忙! 我从这里得到我的文件http://adamw523.com/toronto-geojson/

我希望能得到这样的东西。

旧金山的犯罪率

这是我尝试过的

df_crime=pd.DataFrame(df.Neighbourhood)
df_crime['premisetype']=pd.DataFrame(df.premisetype)
df_crime['offence']=pd.DataFrame(df.offence)
df_crime['MCI']=pd.DataFrame(df.MCI) #major crime indicators e.g. Theft
df_crime['occurrencedate']=pd.DataFrame(df.occurrencedate)
df_crime['reporteddate']=pd.DataFrame(df.reporteddate)
df_crime['occurrencehour'] = df_crime.occurrencedate.dt.strftime('%H:%M')
df_crime['reportedyear'] = df_crime.reporteddate.dt.strftime('%Y')
df_crime['reportedmonth'] = df_crime.reporteddate.dt.strftime('%m')
df_crime['reportedday'] = df_crime.reporteddate.dt.strftime('%d')
df_crime['reportedhour'] = df_crime.reporteddate.dt.strftime('%H:%M')
df_crime['Lat']=pd.DataFrame(df.Lat)
df_crime['Long']=pd.DataFrame(df.Long)
df_crime.head()

我使用的坐标是:

TORONTO_LAT = 43.70011 TORONTO_LONG = -79.4163

我也有这个代码给我计数

df_crime1=df_crime.groupby('Neighbourhood').size().reset_index(name="Count")
world_geo = r'simple.geojson' # geojson file
# create map of Toronto using latitude and longitude values
map_toronto = folium.Map(location=[TORONTO_LAT,TORONTO_LONG ], zoom_start=10)

folium.Choropleth(geo_data=world_geo,
                  data=df_crime1, 
                  columns=['Neighbourhood', 'Count'],
                  key_on='feature.properties.DAUID',
                  fill_color='YlOrRd',
                  fill_opacity=0.7,
                  line_opacity=0.2,
                  legend_name='Crime Rate in Toronto'
                  ).add_to(map_toronto)

map_toronto

这是我得到的图像

多伦多犯罪率

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM