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

python osmnx - extract only big freeways of a country

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

paris_network = ox.gdf_from_place("Paris")

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

france_big_expressway_network = ox.gdf_from_place("France", road_type = "freeway")

我猜它可能来自 "infrastructure" 论点,但作为一个新手,我真的不知道如何准确地使用它。

是的,您可以使用 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)

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

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