Is it possible to show the scale in an OSM tile plot using bokeh?

I am using the OSM tile provider in bokeh to plot a basemap, here is a reference. I am wondering if there is a way to show the scale of the map in meters or kilometers depending on the zoom level.

Just to clarify, the axis labels can remain in WGS84-pseudo-mercator but I want to have a scale or some sort of ruler to give a better sense of the distances in the plot.

Here is an example image from the OSM website where I have marked the scale in the bottom left corner.

A scale annotation seems like s useful thing, but no-one has ever asked for it / done it. A GitHub Issue would be appropriate to suggest it as a new feature. Otherwise you can draw one manually using the axis extents and standard glyphs and annotations (segment, text or Label, etc)

AHEM :innocent: :joy:

Thank you for your fast response. I have opened an issue with a feature suggestion [FEATURE] Show scale in map · Issue #11755 · bokeh/bokeh · GitHub.

@gmerritt123 Have you found/ written a work-around?

I think I did at one point, with this logic. Sorry I can’t find where I implemented it… the joys of changing employers…

  1. I created a datasource for a single line renderer whose coordinates were based on the figure extents (this would be the scale bar)
  2. It would update on zoom (via a CustomJS callback set to js_on_change for every zoom tool on the figure) so the line would always appear in the bottom left (with an offset) and the length of it would always be about 1/3rd of the x extents, rounded to a nice number.
  3. There’d be a label annotation similarly placed (just below the scale bar) that would display the current length of the scale.

Where it broke down was that it basically only worked on maps/figures where the x_scale/y_scales were the same. Having something like an “orientation” option that would make a scale bar showing a y scale bar if “vertical” and x if “horizontal” would be super slick :slight_smile:

@gmerritt123 “asked for it” means “asked for it in an issue on GitHub” because that’s the only centralized place that has even a hope of being tracked over any length of time. If a request is not on GitHub, it does not exist for all practical purposes.

1 Like

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.