我在这里遵循了以下示例:http : //docs.bokeh.org/en/latest/docs/user_guide/geo.html#tile-providers
我得到了一个基本地图,该地图加载了带有多边形列表的GeoJSON文件(已经投影到Web Mercator EPSG:3857),因此可以STAMEN_TONER用作图块提供程序。
from bokeh.io import output_file, show
from bokeh.plotting import figure
from bokeh.tile_providers import STAMEN_TONER, STAMEN_TERRAIN
from bokeh.models import Range1d, GeoJSONDataSource
# bokeh configuration for jupyter
from bokeh.io import output_notebook
output_notebook()
# bounding box (x,y web mercator projection, not lon/lat)
mercator_extent_x = dict(start=x_low, end=x_high, bounds=None)
mercator_extent_y = dict(start=y_low, end=y_high, bounds=None)
x_range1d = Range1d(**mercator_extent_x)
y_range1d = Range1d(**mercator_extent_y)
fig = figure(
tools='pan, zoom_in, zoom_out, box_zoom, reset, save',
x_range=x_range1d,
y_range=y_range1d,
plot_width=800,
plot_height=600
)
fig.axis.visible = False
fig.add_tile(STAMEN_TERRAIN)
# the GeoJSON is already in x,y web mercator projection, not lon/lat
with open('/path/to/my_polygons.geojson', 'r') as f:
my_polygons_geo_json = GeoJSONDataSource(geojson=f.read())
fig.multi_line(
xs='xs',
ys='ys',
line_color='black',
line_width=1,
source=my_polygons_geo_json
)
show(fig)
Run Code Online (Sandbox Code Playgroud)
但是,我无法为图块设置默认的缩放级别。我以为它可能是一种工具设置(http://docs.bokeh.org/en/latest/docs/user_guide/tools.html),但是在那儿我找不到缩放功能的默认值。
如何为图块的缩放级别设置默认值?
老问题,但回答是否有人遇到同样的问题。设置地图范围,这样您就可以在加载时放大到所需的区域。下面以巴布亚新几内亚为例
p = figure(title="PNG Highlands Earthquake 7.5 Affected Villages",y_range=(-4.31509, -7.0341),x_range=( 141.26667, 145.56598))
p.xaxis.axis_label = 'longitude'
p.yaxis.axis_label = 'latitude'
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
1157 次 |
| 最近记录: |