osmextract icon indicating copy to clipboard operation
osmextract copied to clipboard

[FEATURE] allow oe_read and oe_vectortranslate to work with .osm files

Open Robinlovelace opened this issue 2 years ago • 5 comments
trafficstars

As illustrated in the example below.

#| echo: false
#| eval: false
leeds_university = tmaptools::geocode_OSM("university of leeds", as.sf = TRUE)
leeds_smallarea = stplanr::geo_buffer(shp = leeds_university, dist = 1000)
dir.create("example-data")
leeds_bounding_polygon = stplanr::bb2poly(sf::st_bbox(leeds_smallarea))
sf::write_sf(leeds_bounding_polygon, "example-data/leeds_bounding_polygon.geojson")
sf::st_bbox(leeds_smallarea)

OSM data was downloaded from overpass with the following command which uses wget to query the API for the bounding box:

 #| eval: false
wget -O example-data/leeds.osm "https://overpass-api.de/api/interpreter?data=[out:xml][timeout:25];(way[highway](53.797790,-1.571467,53.815759,-1.541108);node(w););out body;>;out skel qt;"

The output of the command above can be found in the example-data folder of this repo.

Quietness

A GeoJSON file with quietness estimates for each road segment in Leeds is available at https://github.com/ITSLeeds/cyclability/raw/main/cyclestreets/leeds_quietness.geojson and is illustrated below:

leeds_quietness = sf::read_sf("https://github.com/ITSLeeds/cyclability/raw/main/cyclestreets/leeds_quietness.geojson")
plot(leeds_quietness["quietness"])
leeds_quietness |>
  sf::st_drop_geometry() |>
  dplyr::slice(1:3) |>
  knitr::kable()
leeds_osm = sf::read_sf("example-data/leeds.osm")
leeds_osm = osmextract::oe_read("example-data/leeds.osm")
osmextract::oe_vectortranslate("example-data/leeds.osm")

Robinlovelace avatar May 07 '23 08:05 Robinlovelace

Hi Robin, should be fixed by https://github.com/ropensci/osmextract/commit/aafd0e429b29d407918dd2b8e838e768c81ee257. Please double-check. I will leave this open since I still need to update docs and tests. The warnings will be fixed when I start working on https://github.com/ropensci/osmextract/issues/275.

agila5 avatar May 07 '23 12:05 agila5

Great work Andrea :fire: will test now...

Robinlovelace avatar May 07 '23 15:05 Robinlovelace

I'm excited by this because it opens-up possiblities of reducing reliance on providers and going directly to overpass-api.de for any size, shape and characteristics of data that people need.

Robinlovelace avatar May 07 '23 15:05 Robinlovelace

Confirmed. It works. See reproducible example in the code committed above. Thoughts on adding a simple interface to the overpass API now this works @agila5? Impressed how little effort that was, high boom for buck!

Robinlovelace avatar May 07 '23 16:05 Robinlovelace

Thoughts on adding a simple interface to the overpass API now this works

We can certainly open a new issue to keep track of that idea but I'm not sure that it is worth the effort since I would just use osmdata 📦 in that case.

agila5 avatar May 10 '23 14:05 agila5