python - Python:如何更新 GeoJSONDataSource?
问题描述
Bokeh 现在支持这使得从这里描述GeoJSONDataSource
的工作和绘制数据变得更加容易。GeoDataFrame
但是我无法更新。假设我们有两个 shapefileshape1.shp
和shape2.shp
. 这就是我正在做的,但我无法更新形状
import geopandas as gpd
from bokeh.plotting import save, figure
from bokeh.models import GeoJSONDataSource
from bokeh.models import Select
from bokeh.io import curdoc
from bokeh.layouts import row, column, widgetbox,layout, gridplot
f1 = gpd.read_file('shape1.shp')
f1g = GeoJSONDataSource(geojson=f1.to_json())
f2 = gpd.read_file('shape2.shp')
f2g = GeoJSONDataSource(geojson=f2.to_json())
select = Select(title="Shape", options = ['F1','F2'], value, ='F1')
geo_source1 = f1g ### first shape
p = figure(plot_width=600,plot_height=500)
p.patches('xs', 'ys', source = geo_source1, fill_color='white')
def update_plot(attrname, old, new):
if select.value == 'F2':
geo_source1.geojson = f1g.geojson #first shape
if select.value == 'F2':
geo_source1.geojson = f2g.geojson #second shape
select.on_change('value', update_plot)
controls = widgetbox(select1)
first_row = row(controls,p)
curdoc().add_root(first_row)
解决方案
推荐阅读
- linux - 不需要验证 ssh 公钥的 bash 脚本
- angular - Spring Boot Rest 调用 - ERR_CONNECTION_REFUSED
- node.js - 有没有办法可以将数据从 nodejs 托管和流式传输到网站?
- ios - 你是如何做到的,所以你不能在 Swift 3 iOS 11 及更高版本的 UICollectionView 中拖动特定的单元格?
- visual-studio-code - MacOS 和 Mono 无法启动 .NET Core 语言服务,因为找不到 `dotnet`
- pytorch - PyTorch 在训练期间对两组梯度进行归一化
- maven - 一些依赖
Maven 在新的 Vaadin 14.0.4 项目中找不到项目 - javascript - 如何制作 Discord 机器人命令?
- firebase - Flutter&Firebase:如何为用户生成递增的数字 ID?
- git - 将 GitHub 私有仓库添加到 Jenkins