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 force osmnx
uses the new settings.py
file?
If I want to make all edges bidirectional, can I just simply set bidirectiional_network_types=['all']
?
The global settings are stored in
settings.py
file. How can I create a new file and forceosmnx
uses the newsettings.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.