简体   繁体   English

如何在bokeh中的GMapPlot上绘制数据着色器图像?

[英]How do I plot a datashader image over a GMapPlot in bokeh?

In bokeh, the InteractiveImage(p, create_image) p parameter is called a base_plot but it's type is a figure . 在bokeh中, InteractiveImage(p, create_image) p参数称为base_plot但它的类型是一个figure The GMapPlot is called a plot but it's type is a model . GMapPlot称为图,但其类型是model

What I'd like is to be able to plot datashaded diagrams on a GMapPlot background. 我想要的是能够在GMapPlot背景上绘制数据阴影图。 Has anyone found how to do this? 有没有人找到如何做到这一点? I can't substitute a GMapPlot in for the p param, and the docs don't (seem to) show me how to combine these InteractiveImage concepts. 我不能用GMapPlot代替p参数,并且文档也没有(似乎)向我展示如何组合这些InteractiveImage概念。

Not sure if an answer is still needed for this, but overlaying interactive datashader plots on top of map data is now very straightforward: 不知道是否仍然需要答案,但是现在将交互式数据着色器图叠加在地图数据之上非常简单:

import pandas as pd, holoviews as hv, geoviews as gv, datashader as ds
from bokeh.models import WMTSTileSource
from holoviews.operation.datashader import datashade
hv.notebook_extension('bokeh')

df = pd.read_hdf('data/census.h5', 'census')
dataset = gv.Dataset(df, kdims=['meterswest', 'metersnorth'], vdims=['race'])

tiles = gv.WMTS(WMTSTileSource(url=\
'https://server.arcgisonline.com/ArcGIS/rest/services/World_Imagery/MapServer/tile/{Z}/{Y}/{X}.jpg'))

color_key = {'w':'blue', 'b':'green', 'a':'red', 'h':'orange', 'o':'saddlebrown'}

tiles * datashade(dataset, x_sampling=10, y_sampling=10, cmap=color_key,
                  element_type=gv.Image, aggregator=ds.count_cat('race'))

resulting in: 导致:

在地图图块上叠加人口普查数据

(See full notebook at https://anaconda.org/jbednar/census-hv/notebook ) (请参阅完整的笔记本, 网址https://anaconda.org/jbednar/census-hv/notebook

It's not GMapPlot per se, but fills many of the same needs. 它本身不是GMapPlot,但可以满足许多相同的需求。 It should also be possible to overlay on GMapPlot, and if that's still needed, please file an issue at the datashader github site. 也应该可以在GMapPlot上叠加,如果仍然需要,请在datashader github站点上提交问题。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM