I’m trying to add a BBoxTileSource in Bokeh where the imagery is exposed via WMS, so I’m testing against the USGS Topo data. Here is my app:
#! /usr/bin/env python
···
import sys
import logging
from bokeh.plotting import figure
from bokeh.layouts import row
from bokeh.models import ColumnDataSource, Range1d, BBoxTileSource
from bokeh.models.renderers import TileRenderer
from bokeh.io import curdoc
logging.basicConfig(stream=sys.stdout, level=logging.DEBUG)
USGS TOPO
url = (‘https://basemap.nationalmap.gov/arcgis/services/’
‘USGSTopo/MapServer/WMSServer?service=WMS’
‘request=GetMap&version=1.3.0&BGCOLOR=0xFFFFFF&&format=image/bmp’
‘crs={crs}&layers={layer}&width={width}&height={height}’)
USGS Test
crs = ‘EPSG:3857’
xmin = -8904681
ymin = 3863947
xmax = -8894269
ymax = 3870320
layer = ‘0’
width = 900
height = 600
url_set = url.format(crs=crs, width=width, height=height, layer=layer) +
‘&bbox={XMIN},{YMIN},{XMAX},{YMAX}’
x_range = Range1d(start=xmin, end=xmax, bounds=None)
y_range = Range1d(start=ymin, end=ymax, bounds=None)
fig = figure(tools=‘wheel_zoom,pan’,
x_range=x_range,
lod_threshold=None,
plot_width=width,
plot_height=height,
background_fill_color=‘white’,
y_range=y_range,)
# x_axis_type=“mercator”,
# y_axis_type=“mercator”)
tile_source = BBoxTileSource(url=url_set)
fig.add_tile(tile_source)
Some Testing glyphs
source = ColumnDataSource(
data=dict(lat=[ymin, ymin, ymax, ymax ],
lon=[xmin, xmax, xmin, xmax ])
)
fig.circle(x=“lon”, y=“lat”, size=15, fill_color=“blue”, fill_alpha=0.8,
source=source)
layout = row(fig)
curdoc().add_root(layout)
curdoc().title = “WMS Viewer”
``
When I view the app the points are displayed, but the tiles are not, and I get no errors anywhere. Any idea what I’m doing wrong here?
System Specs:
- Ubuntu 16.04
- python 3.6
- Bokeh 0.12.15
Installed via conda:
conda create -n wms-env bokeh python=3.6 -c conda-forge
``