我试图在地图上叠加交互式数据分析器图,我只得到"地图数据尚未可用"背景而不是地图背景。我尝试过不同的地图服务和不同的地图,但都没有。 以下是我为类似数据集找到的代码:
import bokeh.plotting as bp
from bokeh.models.tiles import WMTSTileSource
bp.output_notebook()
def base_plot(tools='pan,wheel_zoom,reset',webgl=False):
p = bp.figure(tools=tools,
plot_width=int(850), plot_height=int(500),
x_range=x_range, y_range=y_range, outline_line_color=None,
min_border=0, min_border_left=0, min_border_right=0,
min_border_top=0, min_border_bottom=0, webgl=webgl)
p.axis.visible = False
p.xgrid.grid_line_color = None
p.ygrid.grid_line_color = None
return p
-
background = "black"
from datashader.bokeh_ext import InteractiveImage
def image_callback(x_range, y_range, w, h, color_fn=tf.shade):
cvs = ds.Canvas(plot_width=w, plot_height=h, x_range=x_range, y_range=y_range)
agg = cvs.points(df, 'Dropoff_longitude', 'Dropoff_latitude', ds.count('Passenger_count'))
image = color_fn(agg)
return tf.dynspread(image,threshold=0.75, max_px=8)
#return(image)
p = base_plot()
url="https://server.arcgisonline.com/ArcGIS/rest/services/World_Imagery/MapServer/tile/{Z}/{Y}/{X}.png"
#url="http://tile.stamen.com/toner-background/{Z}/{X}/{Y}.png"
tile_renderer = p.add_tile(WMTSTileSource(url=url))
tile_renderer.alpha=1.0 if background == "black" else 0.15
InteractiveImage(p, image_callback)
以下是对输出的看法:
有谁知道为什么会这样?
提前致谢!