Manuel Salas
Manuel Salas

Reputation: 13

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)

Upvotes: 1

Views: 71

Answers (2)

dbo
dbo

Reputation: 11

In case helpful; filters are also listed at source in the function: def _get_network_filter in _overpass.py : https://github.com/gboeing/osmnx/blob/main/osmnx/_overpass.py

Upvotes: 1

I_Al-thamary
I_Al-thamary

Reputation: 4043

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:

  • motorway, motorway_link
  • trunk, trunk_link
  • primary, primary_link
  • secondary, secondary_link
  • tertiary, tertiary_link
  • unclassified, residential
  • living_street, service
import osmnx as ox

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

2. drive_service

Included Highway Types:

  • All types in drive
  • Additional minor service roads
G = ox.graph_from_place('Your Location', network_type='drive_service')

3. bike

Included Highway Types:

  • cycleway
  • primary, primary_link
  • secondary, secondary_link
  • tertiary, tertiary_link
  • unclassified, residential
  • living_street, service
  • path, road, track
G = ox.graph_from_place('Your Location', network_type='bike')

4. walk

Included Highway Types:

  • footway, pedestrian
  • path, steps
  • residential, living_street
  • service
  • cycleway, road (for crossings and walkways)
G = ox.graph_from_place('Your Location', network_type='walk')

5. all

Included Highway Types:

  • Major Roads: motorway, trunk, primary, etc.
  • Local Roads: unclassified, residential, service, etc.
  • Pedestrian Paths: footway, pedestrian, path, etc.
  • Others: cycleway, steps, track, bridleway, raceway, busway, etc.
G = ox.graph_from_place('Your Location', network_type='all')

6. all_private

Included Highway Types:

  • All types in all
  • Private roads and paths not typically public
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)

Upvotes: 0

Related Questions