osmnx

osmnx python network_type filters


I am getting familiar with the package and I have been trying to find a list of all the possible custom filters for network_type.

Looking directly at the code has provided some ideas, but I wonder if there is a list somewhere with all the type of filters (motorway, primary, residential) per network_type (drive, walking,bike)


Solution

  • Here is a link to all the types of filters road network analysis and OpenStreetMap Wiki.

    The network_type parameter allows you to specify the type of network (e.g., driving, walking, biking). Each network_type includes a predefined set of OSM highway tags.

    1. drive

    Included Highway Types:

    import osmnx as ox
    
    # Fetch driving network
    G = ox.graph_from_place('Your Location', network_type='drive')
    

    2. drive_service

    Included Highway Types:

    G = ox.graph_from_place('Your Location', network_type='drive_service')
    

    3. bike

    Included Highway Types:

    G = ox.graph_from_place('Your Location', network_type='bike')
    

    4. walk

    Included Highway Types:

    G = ox.graph_from_place('Your Location', network_type='walk')
    

    5. all

    Included Highway Types:

    G = ox.graph_from_place('Your Location', network_type='all')
    

    6. all_private

    Included Highway Types:

    G = ox.graph_from_place('Your Location', network_type='all_private')
    

    You can use a Custom filter

    highway_types = [
        'motorway', 'trunk', 'primary', 'secondary', 'tertiary', 'residential', 'unclassified',
        'motorway_link', 'trunk_link', 'primary_link', 'secondary_link', 'tertiary_link',
        'living_street', 'service', 'road'
    ]
    
     
    custom_filter = '["highway"~"{}"]'.format('|'.join(highway_types))
    
    G = ox.graph_from_place('Your Location', custom_filter=custom_filter)