Is there any way to specify multiple subcategories for an infrastructure type while importing roads using osmnx. From this question I understand that we can select only freeways by specifying infrastructure='way["highway"~"motorway"]'
. How can we expand this to include multiple categories such as highways = motorway or primary or secondary
or highway is not footway
I tried the following without success:
infrastructure='way["highway"~"motorway"],way["highway"~"primary"]'
infrastructure='way["highway"~"motorway", "primary"]'
infrastructure='way["highway"~"motorway" OR "primary"]'
It would be nice to have better filtering such as highway=primary or highway=primary_link
(examples here , keys here)
Use the pipe |
as an overpass or
operator like:
import osmnx as ox
ox.settings.log_console = True
place = 'Berkeley, California, USA'
cf = '["highway"~"motorway|motorway_link"]'
G = ox.graph_from_place(place, network_type='drive', custom_filter=cf)
print(len(G)) #36
cf = '["highway"~"primary"]'
G = ox.graph_from_place(place, network_type='drive', custom_filter=cf)
print(len(G)) #11
cf = '["highway"~"motorway|motorway_link|primary"]'
G = ox.graph_from_place(place, network_type='drive', custom_filter=cf)
print(len(G)) #47