python osmnx - 只提取一个国家的大高速公路

han*_*ick 5 python openstreetmap osmnx

我知道可以通过 OSMNX python 包提取城市的道路网络。请参阅https://geoffboeing.com/2016/11/osmnx-python-street-networks/ 的详细信息。

paris_network = ox.gdf_from_place("Paris")
Run Code Online (Sandbox Code Playgroud)

但是,假设我不想要那种高度的细节,而只想要整个国家的大高速公路。我正在寻找类似的东西:

france_big_expressway_network = ox.gdf_from_place("France", road_type = "freeway")
Run Code Online (Sandbox Code Playgroud)

我想它可能来自“基础设施”的论点,但作为一个新手,我真的不知道如何准确地使用它。

gbo*_*ing 8

是的,您可以使用 OSMnx 执行此操作:

import osmnx as ox
ox.config(use_cache=True, log_console=True)
G = ox.graph_from_place('France', network_type='drive', custom_filter='["highway"~"motorway"]')
fig, ax = ox.plot_graph(G)
Run Code Online (Sandbox Code Playgroud)

如果您想按多个高速公路标签值进行过滤(例如,保留所有高速公路和主要道路),另请参阅此答案

最后,请注意,从 OSMnx v0.15.0 开始,gdf_from_placegdf_from_places函数已被弃用并由geocode_to_gdf函数替换。有关详细信息,请参阅文档

  • 我用它来表示“巴西”,它吃掉了我们服务器的所有 150GB RAM,然后 python 内核死掉了! (2认同)