3

Google maps in Bokeh has become too difficult with their API keys and registration, so I'm exploring alternatives but really like the Bokeh framework, especially with periodic callbacks.

What's the right way to coerce Bokeh to update the basemap tile better? I assume map tiles are supposed to be updated automatically, and they are, sort of, but it's not working as well as expected.

Here's a simple code clip to convert (lat/lon) pairs into Northing and Easting values to display a region of a basemap.

Zooming and panning works but sometimes leaves large blank tiles that never fill-in.

How can this be addressed?

from bokeh.plotting import figure, show, output_file, curdoc
from bokeh.models.widgets import Slider, Div
from bokeh.layouts import column, layout
from bokeh.tile_providers import get_provider, Vendors
from pyproj import Proj, transform

def LatLon_to_EN(lat, lon):
    try:
      easting, northing = transform( Proj('epsg:4326'), Proj('epsg:3857'), lat, lon) # from WGS-84 to Web Mercator Easting/Northing
      return easting, northing
    except:
      return None, None

tile_provider = get_provider(Vendors.STAMEN_TERRAIN_RETINA)
#tile_provider = get_provider(Vendors.STAMEN_TERRAIN)

# SouthWest and NorthEast corners
SW_corner=(29.191391, -81.049014) # center of campus foot bridge
NE_corner=(29.239598, -80.949180) # out in the ocean

# Convert to mercator Easting and Northing coordinates
SW_corner_EN = LatLon_to_EN( SW_corner[0] , SW_corner[1] )
NE_corner_EN = LatLon_to_EN( NE_corner[0] , NE_corner[1] )

# x_axis_type, y_axis_type may be: "linear", "log", "datetime", "mercator"
plot = figure(x_range=(SW_corner_EN[0], NE_corner_EN[0]), y_range=(SW_corner_EN[1], NE_corner_EN[1]), x_axis_type="mercator", y_axis_type="mercator")
plot.add_tile(tile_provider)

curdoc().add_root(plot)
curdoc().title = "Bokeh example for basemap with non-Google tile providers"

1 Answer 1

2

The Bokeh project has Incorporated new basemap tile providers similar to geoviews. The Bokeh project released these updates in version 2.0 described in a March 9th, 2020 article here: https://medium.com/@bokeh/announcing-bokeh-2-0-647042d0d977

Detailed discussion is on discourse.bokeh.org here: https://discourse.bokeh.org/t/open-source-tile-provider-replacement-for-google-maps/4462

and here: https://github.com/bokeh/bokeh/pull/9582

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.