I am failing to implement box_select behaviour when using geopandas data. The tool is shown and can be chosen, however nothing happens upon selection made (with shift key held or without). I’ve now tried this on two seperate shapefiles and got the same problem.
Tap select seems to work fine and so does box zoom.
any ideas?
UPDATE: found this post from 2015-6, not sure if it has been implemented since?
code below, example data from this link. Thanks
from pathlib import Path
import geopandas as gpd
import json
import os
from bokeh.models import GeoJSONDataSource, TapTool, HoverTool
from bokeh.plotting import figure
from bokeh.models import BoxSelectTool
#notebook environment
from bokeh.io import show, output_notebook
output_notebook()
dataFolder = Path(os.getcwd()).parent
dataFolder = os.path.join(dataFolder, "data")
shapefile = os.path.join (str(dataFolder) + '/USA Counties 20m/cb_2017_us_county_20m_with_cZone_USAF_coordinates_elevations_timezones.shp')
#Read shapefile using Geopandas
gdf = gpd.read_file(shapefile)
print ('SHP file loaded successfully')
#Read data to json.
json_raw = json.loads(gdf.to_json())
#Convert to String like object.
json_data = json.dumps(json_raw)
#Input GeoJSON source that contains features for plotting.
geosource = GeoJSONDataSource(geojson = json_data)
p = figure(title = 'SF Landuse Map', plot_height = 450 , plot_width = 750, toolbar_location = "below")
box_select = BoxSelectTool()
p.add_tools(box_select)
p.patches('xs','ys', source = geosource, line_color = 'black', line_width = 0.01, fill_alpha = 1)
show(p)