私は 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...
基本的に gdf をBeat_numとYearでグループ化し、各グループの 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))