博凯:有没有可能改变坐标系博凯。瓦卢?

2024-04-19 10:56:07 发布

您现在位置:Python中文网/ 问答频道 /正文

我想知道是否有可能在Bokeh中添加一个tile,使用不同的坐标系引用

from bokeh.plotting import figure, show, output_file
from bokeh.tile_providers import get_provider, Vendors

output_file("tile.html")

tile_provider = get_provider(Vendors.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)

Tags: fromimportoutputgettypeshowbokehrange
1条回答
网友
1楼 · 发布于 2024-04-19 10:56:07

我强烈建议你去看看建在bokeh和cartopy之上的Goviews图书馆。你知道吗

documentation为使用不同的参考系统提供了很好的例子:

import geoviews as gv
import geoviews.feature as gf

from geoviews import opts
from cartopy import crs

gv.extension('bokeh', 'matplotlib')


nyc, beijing = (-74.0, 40.7, 'NYC'), (116.4, 39.9, 'Beijing')
london = (14471.53, 6712008., 'London')

cities_lonlat   = gv.Points([nyc, beijing], vdims='City')
cities_mercator = gv.Points([london], crs=crs.GOOGLE_MERCATOR, vdims='City')

(gv.tile_sources.Wikipedia * cities_lonlat * cities_mercator).opts(
    opts.Points(global_extent=True, width=500, height=475, size=12, color='black'))

result

相关问题 更多 >