[英]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.