-
Notifications
You must be signed in to change notification settings - Fork 524
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add example for OR condition in custom filter #90
Comments
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. |
So an Overpass Turbo query to perform a union operation looks something like this:
This example will return all the ways tagged railway=light_rail and all the ways tagged highway=primary. As you might notice, this doesn't work with the OSMnx So then how to you create a graph of the union of multiple infrastructure types? See here and here. The short story is you use import networkx as nx
import osmnx as ox
place = 'Some City'
G1 = ox.graph_from_place(place, custom_filter='["highway"~"primary"]')
G2 = ox.graph_from_place(place, custom_filter='["railway"~"light_rail"]')
G = nx.compose(G1, G2) This will generate essentially the same result as the OverpassQL union above. All that said, it's worth noting that the OSMnx |
See also gboeing/osmnx#1199 |
Thank you for your eMail!
I am on travel with limited email access until the end of August. In urgent matters regarding activities at KISD, please be in touch with our secretariat via eMail office(at)kisd.de
Thank you very much!
Prof. Philipp Heidkamp, KISD (Köln International School of Design)
|
I will add an example here next time I update the repo to demonstrate the enhancement (gboeing/osmnx#1204) of passing a list to |
I would be curious on how to do more advanced custom filters, for example how to combine two (in and OR fasion).
Possible syntax and examples of more advanced custom filter could be added to 08-custom-filters-infrastructure.ipynb
The text was updated successfully, but these errors were encountered: