gboeing / osmnx-examples

Gallery of OSMnx tutorials, usage examples, and feature demonstations.
https://osmnx.readthedocs.io
MIT License
1.5k stars 519 forks source link

Add example for OR condition in custom filter #90

Open EwoutH opened 1 week ago

EwoutH commented 1 week ago

I would be curious on how to do more advanced custom filters, for example how to combine two (in and OR fasion).

custom_filter = '["highway"~"motorway|motorway_link"]'
construction_filter = '["construction"~"motorway|motorway_link"]'
full_filter = ???

Possible syntax and examples of more advanced custom filter could be added to 08-custom-filters-infrastructure.ipynb

EwoutH commented 1 week ago

Taking a look back at an old notebook I once applied this trick:

road_types = '["highway"~"motorway|trunk|primary|secondary|tertiary|motorway_link|trunk_link|primary_link|secondary_link|tertiary_link|construction"]["construction"!~"unclassified|residential|living_street|road|raceway|pedestrian|service|track|bridleway|cycleway|footway|path|steps"]'

But I think this should be able to done more elegant and robust.