☰Read-only archive⌕
Looking for help with Bokeh?

This is a read-only archive. Ask questions and join the conversation on GitHub.

Visit Community Support on GitHub →
Archived discussions · Captured October 28, 2026

Plotting geo data raw mecator vs lan/lon

Community Support
Maxxner
Maxxner

I am wondering how the conversions between raw mecator geo data and geo json data with latitude and longitude are supposed to be handled. Is there any built-in functionality for this problem?

Currently the example code is pretty confusing: " Notice that passing x_axis_type="mercator" and y_axis_type="mercator" to figure generates axes with latitude and longitude labels, instead of raw Web Mercator coordinates."
However that only seems to affect the label, any data still must provided in raw mercator coordinates.
So do I have to write my own custom function to handle the conversion if my data source is in a GeoJSON format?

from bokeh.plotting import figure, output_file, show
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)
⌁   Link to post
Bryan
Bryan

There are not functions built in to Bokeh. There are existing specialized libraries like pyproj that handle GIS conversions far better than Bokeh ever could.

Currently the example code is pretty confusing: " Notice that passing x_axis_type="mercator" and y_axis_type="mercator" to figure generates axes with latitude and longitude labels, instead of raw Web Mercator coordinates."

The axes are for mercator coordinates. There probably was not any name choice here that would be obvious to 100% of people.

So do I have to write my own custom function to handle the conversion if my data source is in a GeoJSON format?

I guess I would phrase it differently, i.e. you need to utilize tools that specialize and are good at these conversions. I believe geopandas can do this or shapely, with a few more lines. [1]


  1. Just FYI, the GeoJSON spec admits non-geographic coordinates: “However, where all involved parties have a prior arrangement, alternative coordinate reference systems can be used without risk of data being misinterpreted.” ↩︎

⌁   Link to post

End of archived discussion · Replies are disabled