Hi. I’m hoping this is a relatively straightforward query, and I’ve just misunderstood how to link two items.
I have a GeoPandas DataFrame from which I am plotting polygons in Geoviews. I have a separate Pandas DataFrame that contains some data that I want to plot. I don’t want to join the DataFrames but I would like that when a user clicks a polygon, all the information in the GeoPandas Dataframe row behind that polygon is passed to a variable that can be used to slice the Pandas DataFrame. Using some of the help in this forum I have the following code, and I know that
sel.index holds the polygon index.
I just don’t understand how to set up the interactivity. Any guidance would be really appreciated.
import geopandas as gpd import geoviews as gv import holoviews as hv gv.extension('bokeh') hv.extension('bokeh') df = gpd.read_file('https://raw.githubusercontent.com/ajggeoger/JNCCLocalIndex/main/data/DarkPeak/datasubset.geojson') to_keep = ['polygon_id', 'ID', 'main_habit', 'Confidence', 'Area_Ha', 'geometry'] mydf = df[to_keep] mydf = mydf.to_crs("EPSG:4326") polys = gv.Polygons(mydf, vdims=['main_habit']) sel = hv.streams.Selection1D(source=polys)#, index=) polys.opts( tools=['hover', 'tap'], width=600, ) pn.Row(polys, mydf.iloc[sel.index]) # but what I really want is the information from mydf to be updated every time a polygon is clicked # and for it to be saved as a variable that I can use to slice a different dataframe