I was trying to find a module to visualize some geographical data in python. So I was trying to use bokeh library for this purpose. But when I was learning how to use Bokeh lib from their user guide I got some error. The code I was trying to run is :
from bokeh.plotting import figure, show
# range bounds supplied in web mercator coordinates
p = figure(x_range=(-2000000, 2000000), y_range=(1000000, 7000000),
x_axis_type="mercator", y_axis_type="mercator")
p.add_tile("CartoDB Positron", retina=True)
show(p)
And it raised:
ValueError: failed to validate TileRenderer(id='1041', ...).tile_source: expected an instance of type TileSource, got CartoDB Positron of type str
Athough the code is just copied from their tutorial it doesn't work. Versions of the env:
This is possible because of the xyzservices which bokeh is calling but it seems bokeh doesn't aware of the problem. Here is the user guide page on bokeh:
[https://docs.bokeh.org/en/latest/docs/user_guide/topics/geo.html][1]
So what do you guys think?
The documentation example is the example of the latest Version. (>3.0.0)
I found this slightly altered example for 2.4.3 (https://docs.bokeh.org/en/2.4.3/docs/user_guide/geo.html#userguide-geo):
from bokeh.tile_providers import CARTODBPOSITRON, get_provider
output_file("tile.html")
tile_provider = get_provider(CARTODBPOSITRON)
# range bounds supplied in web mercator coordinates
p = figure(x_range=(-2000000, 6000000), y_range=(-1000000, 7000000),
x_axis_type="mercator", y_axis_type="mercator")
p.add_tile(tile_provider)
show(p)