我正在研究 GeoViews,我想知道我们是否可以将滑块作为 GeoViews 中等值线地图的输入。
我在 gdf 中有另一个变量,即年份。是否可以有一个滑块来显示年度 Total_Crimes?
编辑:添加了更多信息:
gdf 数据框具有以下变量。
beat_num Year Total_Crimes beat district sector geometry
111 2012 1449 1 01 1 POLYGON ((-87.62451050462798 41.88829675314376...
111 2013 1645 1 01 1 POLYGON ((-87.62451050462798 41.88829675314376...
111 2014 1636 1 01 1 POLYGON ((-87.62451050462798 41.88829675314376...
111 2015 1642 1 01 1 POLYGON ((-87.62451050462798 41.88829675314376...
111 2016 1836 1 01 1 POLYGON ((-87.62451050462798 41.88829675314376...
我基本上按beat_num和Year对 gdf 进行了分组,并找出了每个组的 Total_Crimes。gdf 的数据类型:
beat_num int64
Year int64
Total_Crimes int64
beat object
district object
sector object
geometry object
完整代码:
import geopandas as gpd
import holoviews as hv
import geoviews as gv
import geoviews.tile_sources as gts
hv.extension('bokeh')
geometries = gpd.read_file('geo_export_3b3b25c2-a600-40c3-a663-2f7ad8dc2b9c.shp')
#Reading the shape file for each beat_num.
geometries['beat_num']=geometries['beat_num'].apply(int)
#Converted the beat_num to integers
gdf = gpd.GeoDataFrame(pd.merge(ca_df, geometries))
#dataframe ca_df has total crimes for each beat_num and each year and merged it with geometries to get shape for each beat_num.
plot_opts = dict(tools=['hover'], width=750, height=700, color_index='Total_Crimes',
colorbar=True, toolbar='above', xaxis=None, yaxis=None)
gts.ESRI *gv.Polygons(gdf, vdims=['beat_num', 'Total_Crimes'], label='Chicago Crime Data').opts(plot=plot_opts,style=dict(alpha=0.7))