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)
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’ll add that I’ve used proj4js for Javascript side reprojection in a number of instances as well. But yeah in general pyproj and geopandas’ “crs” and “to_crs” do 99% of the projection work for me in my projects.