【发布时间】:2018-05-26 19:33:05
【问题描述】:
我正在尝试使用 OSMnx 在同一个图中绘制多个基础设施网络(例如街道、铁路和建筑物),但并没有真正成功。
这是我的尝试之一:
import osmnx as ox
dist = 2000
point = (41.877092, -87.628)
north, south, east, west = ox.bbox_from_point(point, distance=dist)
bbox_proj = ox.bbox_from_point(point, dist, project_utm=True)
streets = ox.core.osm_net_download(
north=north,
south=south,
east=east,
west=west,
infrastructure='way["highway"]'
)
railways = ox.core.osm_net_download(
north=north,
south=south,
east=east,
west=west,
infrastructure='way["railway"]'
)
buildings = ox.core.osm_net_download(
north=north,
south=south,
east=east,
west=west,
infrastructure='way["building"]'
)
streets[0]['elements'] = streets[0]['elements'] + railways[0]['elements'] + buildings[0]['elements']
net = streets
G = ox.core.create_graph(net)
G = ox.truncate_graph_bbox(G, north, south, east, west, truncate_by_edge=True)
G = ox.project_graph(G)
_, _ = ox.plot.plot_graph(G, bbox=bbox_proj, fig_height=10, node_size=0, edge_color='black', edge_linewidth=0.5, save=True)
此代码的结果仅绘制了前 2 个基础设施、街道和铁路,而不是建筑物:
ox.plot_figure_ground 的结果(仅绘制街道基础设施):
尽管没有绘制建筑物数据,但仍在下载建筑物数据(我知道 plot_buildings,但我不想要彩色建筑物,只需要线条)。
在此之前,我试图找到一种在infrastructure 参数中一次添加多个过滤器的方法。比如:
nets = ox.core.osm_net_download(
north=north,
south=south,
east=east,
west=west,
infrastructure='way["highway"],way["railway"],way["buildings"]'
)
但不确定这是否可能。
有什么方法可以在一个图中绘制两个以上的图形,如果可能的话,在 OSMnx 中简洁地绘制?
【问题讨论】:
标签: python plot openstreetmap networkx