osmextract icon indicating copy to clipboard operation
osmextract copied to clipboard

Benchmarks and documentation on when to use geofabrik

Open Robinlovelace opened this issue 5 years ago • 1 comments

It's clear that there are many cases when bulk extract download is not the best way to get OSM data. Would be useful to users to know when osmdata is quicker.

Example: you want cycleways in Louvain-la-Neuve in Belgium. With geofabrik:

# remotes::install_github("itsleeds/geofabrik")
library(geofabrik)
lvn_centroid = tmaptools::geocode_OSM("louvain-la-neuve", as.sf = T)
system.time({ # around 2 seconds
  lvn = get_geofabrik(lvn_centroid)
  })
#> although coordinates are longitude/latitude, st_contains assumes that they are planar
#> The place is within these geofabrik zones: Europe, Belgium
#> Selecting the smallest: Belgium
#> Downloading http://download.geofabrik.de/europe/belgium-latest.osm.pbf to 
#> ~/h/data/osm/Belgium.osm.pbf
#> Old attributes: attributes=name,highway,waterway,aerialway,barrier,man_made
#> New attributes: attributes=name,highway,waterway,aerialway,barrier,man_made,maxspeed,oneway,building,surface,landuse,natural,start_date,wall,service,lanes,layer,tracktype,bridge,foot,bicycle,lit,railway,footway
#> Using ini file that can can be edited with file.edit(/tmp/RtmprktWUQ/ini_new.ini)
#>    user  system elapsed 
#>  72.514  18.150 269.507
plot(louvain_highway)

Created on 2020-02-06 by the reprex package (v0.3.0)

Robinlovelace avatar Feb 06 '20 06:02 Robinlovelace

Equivalent code in osmdata takes 2 seconds!

library(osmdata)
library(sf)
system.time({ # around 2 seconds
  n = "louvain-la-neuve"
  v = "primary|secondary|cycleway"
  louvain = opq(n) %>% 
  add_osm_feature("highway", v,
    value_exact = F) %>%
  osmdata_sf()
  })
#>    user  system elapsed 
#>   0.125   0.020   1.814
louvain_highway = louvain$osm_lines
plot(louvain_highway)

Robinlovelace avatar Feb 06 '20 06:02 Robinlovelace