将osmnx中的道路网络改为双向。

huangapple go评论87阅读模式
英文:

Change road network to bidirectional in osmnx

问题

我想知道是否可以使用osmnx将所有道路网络设置为双向?我希望它是双向的,而不是无向的,因为我仍然希望使用一些函数,比如osmnx.truncate。所以osmnx.get_undirected(G)不能帮助我。

我看到@gboeing提到可以通过更改全局设置来实现这一点。但我不确定如何做到这一点。有两个问题:

  1. 全局设置存储在settings.py文件中。我如何创建一个新文件并强制osmnx使用新的settings.py文件?

  2. 如果我想使所有边都是双向的,我只需简单地设置bidirectiional_network_types=['all']吗?

英文:

I wonder if I can set all road networks to bidirectional using osmnx? I hope it is bidirectional rather than undirected because I still hope to use some functions like osmnx.truncate. So osmnx.get_undirected(G) cannot help me.

I saw @gboeing mentioned this can be done by changing the global settings. But I am not sure how to do that. Two questions

  1. The global settings are stored in settings.py file. How can I create a new file and force osmnx uses the new settings.pyfile?

  2. If I want to make all edges bidirectional, can I just simply set bidirectiional_network_types=['all']?

答案1

得分: 1

全局设置存储在 settings.py 文件中。如何创建一个新文件并强制 osmnx 使用新的 settings.py 文件?

您可以通过在 osmnx.settings 内设置变量来更改 osmnx 设置。示例:

import osmnx
osmnx.settings.bidirectional_network_types = ["walk", "drive"]

如果我想使所有边都是双向的,我只需简单地设置 bidirectional_network_types=["all"] 吗?

不,这不会起作用。您要使双向的网络类型必须与您在函数中使用的 network_type 匹配,例如 graph_from_address()。在检查 bidirectional_network_types 列表时,它会按照以下方式检查:

bidirectional = network_type in settings.bidirectional_network_types

换句话说,参数 network_type 必须与 bidirectional_network_types 中的一个条目完全匹配,才能被视为双向网络。

英文:

>The global settings are stored in settings.py file. How can I create a new file and force osmnx uses the new settings.pyfile?

You can alter osmnx settings by setting variables within osmnx.settings. Example:

import osmnx
osmnx.settings.bidirectional_network_types = ["walk", "drive"]

>If I want to make all edges bidirectional, can I just simply set bidirectiional_network_types=['all']?

No, that will not work. The network type you are making bidirectional must match the network_type you're using in functions such as graph_from_address(). When it checks the bidirectional_network_types list, it checks it in the following fashion:

bidirectional = network_type in settings.bidirectional_network_types

In other words, the argument network_type must exactly match one of the entries inside bidirectional_network_types to be treated as a bidirectional network.

huangapple
  • 本文由 发表于 2023年6月22日 04:59:37
  • 转载请务必保留本文链接:https://go.coder-hub.com/76527096.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定