英文:
Change road network to bidirectional in osmnx
问题
我想知道是否可以使用osmnx将所有道路网络设置为双向?我希望它是双向的,而不是无向的,因为我仍然希望使用一些函数,比如osmnx.truncate
。所以osmnx.get_undirected(G)
不能帮助我。
我看到@gboeing提到可以通过更改全局设置来实现这一点。但我不确定如何做到这一点。有两个问题:
-
全局设置存储在
settings.py
文件中。我如何创建一个新文件并强制osmnx
使用新的settings.py
文件? -
如果我想使所有边都是双向的,我只需简单地设置
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
-
The global settings are stored in
settings.py
file. How can I create a new file and forceosmnx
uses the newsettings.py
file? -
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.py
file?
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.
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论