-
Notifications
You must be signed in to change notification settings - Fork 821
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
Union filters #1204
Union filters #1204
Conversation
Would something like this be possible? How would that work API wise in with this PR? (see gboeing/osmnx-examples#90) custom_filter = '["highway"~"motorway|motorway_link"]'
construction_filter = '["construction"~"motorway|motorway_link"]'
full_filter = ??? |
@EwoutH for OR filter it will be
|
That’s a really clean syntax, love it! |
@arkty tests are failing. Run the pre-commit hooks locally then push again. |
@gboeing i've added a commit with style fix, can you please run wf again. |
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## tests #1204 +/- ##
==========================================
- Coverage 98.31% 98.27% -0.04%
==========================================
Files 24 24
Lines 2367 2373 +6
==========================================
+ Hits 2327 2332 +5
- Misses 40 41 +1 ☔ View full report in Codecov by Sentry. |
Awesome! Looking forward to using this in the next pre-release! |
Union filters
Discussion: #1199
Problem
When developing city graph models, the size of the resulting graph might be important. Thanks to OSMnx, it's possible to use a pre-defined filters to request a network, based on desired types of OSM ways. But sometimes, it's needed to add an additional ways from OSM into network or union them based on multiple filters.
Technical details
When using
custom_filter
, it's not possible to request additional roads by Overpass union condition.Example
We need to request additional road by name (The Road), ignoring all other conditions.
In Overpass this request will look like this:
OSMnx constructs Overpass request like this, where
$filter
is pre-defined filter or provided by user.Proposal
Make
custom_filter
accepts not only string, but a list of filters and then combine the result into single graph.Because OSMnx already supports sub-divided requests, it's easy to implement this without changing logic on actual graph creation (simplification, connectivity, etc).
Usage example
On example of city Petrozavodsk we will use
graph_from_place
withnetwork_type = "drive"
. This will give us a graph on a perfect level of details. But for some reason, two additional roads are required to be in model.The request below correctly adds these roads.