简体   繁体   中英

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 . The GMapPlot is called a plot but it's type is a model .

What I'd like is to be able to plot datashaded diagrams on a GMapPlot background. 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.

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 )

It's not GMapPlot per se, but fills many of the same needs. It should also be possible to overlay on GMapPlot, and if that's still needed, please file an issue at the datashader github site.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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