[Python] Bokeh Geographical Data Visualization

Discussão em 'Python' iniciado por Stack, Março 23, 2025.

  1. Stack

    Stack Membro Participativo

    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:

    • Python v3.7.7
    • Bokeh v2.4.3

    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?

    Continue reading...

Compartilhe esta Página