How to import multiple infrastructure type in osmnx?

前端 未结 1 1539
Happy的楠姐
Happy的楠姐 2021-01-21 11:46

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

1条回答
  •  庸人自扰
    2021-01-21 12:42

    Use the pipe | as an overpass or operator like:

    import osmnx as ox
    ox.config(use_cache=True, 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
    

    see also https://stackoverflow.com/a/62883614/7321942

    0 讨论(0)
提交回复
热议问题