ropensci / osmextract

Download and import OpenStreetMap data from Geofabrik and other providers
https://docs.ropensci.org/osmextract
GNU General Public License v3.0
167 stars 12 forks source link

Documentation on extending the package #153

Open Robinlovelace opened 3 years ago

Robinlovelace commented 3 years ago

The package is very useful in some areas so I think we should encourage domain-specific functions to be written, e.g. oe_get_cycleways() to get cycleways with the appropriate query. However, such functions are best suited to packages that build on osmextract which I think should be kept to generic functionality to avoid mission creep.

Proposed solution: vignette (or content in a paper/article/blog) documenting how to write functions that extend osmextract, e.g. based on a hypothetical package called osmcycleinfra.

Robinlovelace commented 3 years ago

Ping @mvl22 any ideas on this welcome after conversation today.

mvl22 commented 3 years ago

Yes, I agree that a general-purpose 'mechanics' package like osmextract is probably best not concerned with domain-specific functionality, which is best in a separate package, since that is a higher-level concern.

PS I would flag my usual caution that a function like oe_get_cycleways should be extremely clear as to what it does or doesn't cover. People constantly ask us "how do we get the cycle network from OSM", to which the answer is "please define cycle network". Just getting highway=cycleway is inadequate.

Robinlovelace commented 3 years ago

PS I would flag my usual caution that a function like oe_get_cycleways should be extremely clear as to what it does or doesn't cover. People constantly ask us "how do we get the cycle network from OSM", to which the answer is "please define cycle network".

Agreed.

The documentation of extending this package, and possibly an osmcycleinfra package could help people answer that question : )

Robinlovelace commented 3 years ago

See here for definition of cycleway @mvl22 https://ohsome.org/apps/osm-history-explorer/#/cycleways_w/2020-06-01T00:00:00Z/2/45.4908851942306/9.264549335457264

mvl22 commented 3 years ago

Well, that is one view, yes.

agila5 commented 3 years ago

Hi @Robinlovelace and @mvl22 and thank you for starting this discussion. I'd like to work on this problem in the next days and I was wondering if there are official guidelines on how to subset OSM data for walking/cycling/driving mode of transport. Suggestions are welcome!

Robinlovelace commented 3 years ago

Hi @agila5 see below for a good 'starter for 10' on tags for different modes (walk/bike/drive). Source: https://github.com/gboeing/osmnx/blob/c17ad723223fead5b1cd6d15e60ba91ba5a19154/osmnx/downloader.py

As far as I can tell this is hardcoded specifically for the OSMnx project and it may be good to be more flexible.

I know @mpadge has implemented this functionality for osmdata. Any tips/tricks/ideas Mark?

Cheers!

filters["drive"] = ( f'["highway"]["area"!~"yes"]{settings.default_access}' f'["highway"!~"abandoned|bridleway|bus_guideway|construction|corridor|cycleway|elevator|' f"escalator|footway|path|pedestrian|planned|platform|proposed|raceway|service|" f'steps|track"]' f'["motor_vehicle"!~"no"]["motorcar"!~"no"]' f'["service"!~"alley|driveway|emergency_access|parking|parking_aisle|private"]' ) # drive+service: allow ways tagged 'service' but filter out certain types filters["drive_service"] = ( f'["highway"]["area"!~"yes"]{settings.default_access}' f'["highway"!~"abandoned|bridleway|bus_guideway|construction|corridor|cycleway|elevator|' f'escalator|footway|path|pedestrian|planned|platform|proposed|raceway|steps|track"]' f'["motor_vehicle"!~"no"]["motorcar"!~"no"]' f'["service"!~"emergency_access|parking|parking_aisle|private"]' ) # walking: filter out cycle ways, motor ways, private ways, and anything # specifying foot=no. allow service roads, permitting things like parking # lot lanes, alleys, etc that you *can* walk on even if they're not # exactly pleasant walks. some cycleways may allow pedestrians, but this # filter ignores such cycleways. filters["walk"] = ( f'["highway"]["area"!~"yes"]{settings.default_access}' f'["highway"!~"abandoned|bus_guideway|construction|cycleway|motor|planned|platform|' f'proposed|raceway"]' f'["foot"!~"no"]["service"!~"private"]' ) # biking: filter out foot ways, motor ways, private ways, and anything # specifying biking=no filters["bike"] = ( f'["highway"]["area"!~"yes"]{settings.default_access}' f'["highway"!~"abandoned|bus_guideway|construction|corridor|elevator|escalator|footway|' f'motor|planned|platform|proposed|raceway|steps"]' f'["bicycle"!~"no"]["service"!~"private"]' ) # to download all ways, just filter out everything not currently in use or # that is private-access only filters["all"] = ( f'["highway"]["area"!~"yes"]{settings.default_access}' f'["highway"!~"abandoned|construction|planned|platform|proposed|raceway"]' f'["service"!~"private"]' ) # to download all ways, including private-access ones, just filter out # everything not currently in use filters[ "all_private" ] = '["highway"]["area"!~"yes"]["highway"!~"abandoned|construction|planned|platform|proposed|raceway"]'