Python 在bokeh更新GeoJSONDataSource

Python 在bokeh更新GeoJSONDataSource,python,bokeh,Python,Bokeh,我对bokeh中GeoJSONDataSource的更新函数有问题。 对于下面的代码,我采用了两个脚本——它们运行良好——并将它们添加到一个脚本中 但是,当我执行bokeh-service-app时,我收到以下错误消息,我不明白为什么:304 get/app 这是我的密码: from bokeh.io import curdoc from bokeh.layouts import widgetbox, layout from bokeh.models import HoverTool, GeoJ

我对bokeh中GeoJSONDataSource的更新函数有问题。 对于下面的代码,我采用了两个脚本——它们运行良好——并将它们添加到一个脚本中

但是,当我执行
bokeh-service-app
时,我收到以下错误消息,我不明白为什么:
304 get/app

这是我的密码:

from bokeh.io import curdoc
from bokeh.layouts import widgetbox, layout
from bokeh.models import HoverTool, GeoJSONDataSource, Div, LinearColorMapper, LogColorMapper
from bokeh.plotting import figure
from bokeh.models.widgets.inputs import DatePicker, MultiSelect, Select
import datetime as dt
import pickle
import os
import geopandas as gpd


lin_color_mapper = LinearColorMapper(palette=['#FFFFFF', '#FAFEFF', '#F6FCFF'])
log_color_mapper = LogColorMapper(palette=['#FFFFFF', '#FAFEFF', '#F6FCFF'])
这是博克的一个例子

desc = Div(text=open(os.path.join(os.path.dirname(__file__), "templates/index.html")).read())
这是我的DWH的连接

# get data from DWH
table = ...
下一步我准备好多边形

# get pickle with geometry data
home_dir = os.path.dirname(os.path.realpath(__file__))
file_dir = os.path.join(home_dir, 'static', 'geometry.pickle')

with open(file_dir, 'rb') as file:
   geometry = pickle.load(file)
并将它们与我的数据合并

table = geometry.merge(table, how='inner', right_on='delivery_region', left_on='geometry')
只有一些滑块的东西(这次我剪了很多)

从web添加带有geojson示例的GeoJSONDataSource

# adding the source with some sample date from the web (must be geojson)
geo_source = GeoJSONDataSource(geojson='{'
                                   '"type": "Feature",'
                                   '"geometry": {'
                                   '"type": "Point",'
                                   '"coordinates": [125.6, 10.1]'
                                   '},'
                                   '"properties": {'
                                   '"name": "Dinagat Islands"'
                                   '}'
                                   '}')
创建悬停工具

hover = HoverTool(tooltips=[
    ("Region", "@region"),
    ("Value", "@value")])
建立情节

p = figure(plot_width=600, plot_height=800, x_axis_location=None, 
y_axis_location=None, tools=[hover])
p.grid.grid_line_color = None
p.patches('xs', 'ys', fill_color={'field': 'value', 'transform': lin_color_mapper}, line_color='white', line_width=0.1, source=geo_source)
定义用于为滑块选择正确数据的函数

def select_table():
    selected = table[(table['date'] >= min_date.value) & (table['date'] <= max_date.value)]
    return selected
controls = [min_date, max_date]
for control in controls:
    control.on_change('value', lambda attr, old, new: update())

inputs = widgetbox(*controls)
在这里,我为滑块创建更新

def select_table():
    selected = table[(table['date'] >= min_date.value) & (table['date'] <= max_date.value)]
    return selected
controls = [min_date, max_date]
for control in controls:
    control.on_change('value', lambda attr, old, new: update())

inputs = widgetbox(*controls)
仅限bokeh滑块示例中的布局内容

l = layout([
   [desc],
   [inputs, p], ])

update()
curdoc().add_root(l)
curdoc().title = 'Choropleth Map Test'