Skip to content
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

Benchmarks and documentation on when to use geofabrik #42

Open
Robinlovelace opened this issue Feb 6, 2020 · 1 comment
Open

Benchmarks and documentation on when to use geofabrik #42

Robinlovelace opened this issue Feb 6, 2020 · 1 comment

Comments

@Robinlovelace
Copy link
Member

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
Copy link
Member Author

Robinlovelace commented Feb 6, 2020

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)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant