Python OSMNX-仅提取一个国家的大型高速公路

发布于 2025-01-28 08:29:52 字数 488 浏览 6 评论 0原文

我知道可以通过OSMNX Python软件包提取城市的道路网络。 See details at 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")

我想这可能来自“基础架构”参数,但是作为新手,我真的没有得到如何精确使用它。

I know it is possible to extract the road network of a city via the OSMNX python package. See details at https://geoffboeing.com/2016/11/osmnx-python-street-networks/ .

paris_network = ox.gdf_from_place("Paris")

But, let's say I do not want that level of high details, but rather only big freeways of a whole country. I'm looking for something like :

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

I guess it might comes from the "infrastructure" argument but as a newbie I really do not get how to use it precisely.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

草莓酥 2025-02-04 08:29:52

是的,您可以使用OSMNX进行此操作:

import osmnx as ox
ox.settings.log_console = True
cf = '["highway"~"motorway"]'
G = ox.graph_from_place('France', network_type='drive', custom_filter=cf)
fig, ax = ox.plot_graph(G)

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

有关更多用法详细信息,请参见 osmnx docs 有关更多用法详细信息。

Yes you can do this with OSMnx:

import osmnx as ox
ox.settings.log_console = True
cf = '["highway"~"motorway"]'
G = ox.graph_from_place('France', network_type='drive', custom_filter=cf)
fig, ax = ox.plot_graph(G)

See also this answer if you'd like to filter by multiple highway tag values (e.g., retain all motorways AND primary roads).

See the OSMnx docs for more usage details.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文