ropensci / osmdata

R package for downloading OpenStreetMap data
https://docs.ropensci.org/osmdata
317 stars 45 forks source link

Example 2.2 of vignette not working? #120

Closed ghost closed 6 years ago

ghost commented 6 years ago

When I attempt the following example from section 2.2: https://github.com/ropensci/osmdata/blob/master/vignettes/osmdata.Rmd

q1 <- opq('Seville') %>%
    add_osm_feature(key = 'highway', value = 'cycleway')
cway_sev <- osmdata_sp(q1)
sp::plot(cway_sev$osm_lines)

I'm getting the following error:

Error in (function (xlim, ylim, log = "", asp = NA, ...) : need finite 'xlim' values

If I print the cway_sev$osm_lines object, I get the following output:

An object of class "SpatialLinesDataFrame"
Slot "data":
data frame with 0 columns and 0 rows

Slot "lines":
named list()

Slot "bbox":
            min            max
x 1.797693e+308 -1.797693e+308
y 1.797693e+308 -1.797693e+308

Slot "proj4string":
CRS arguments:
 +proj=longlat +ellps=WGS84 +datum=WGS84 +no_defs +towgs84=0,0,0 
Robinlovelace commented 6 years ago

Confirmed. The cause of this is that the first hit for Seville is now in the USA. I think setting it to seville spain or sevilla will solve it. You can it's in the US by looking at the bbox:

library(osmdata)
#> Data (c) OpenStreetMap contributors, ODbL 1.0. http://www.openstreetmap.org/copyright
q1 <- opq("Seville") %>% add_osm_feature(key = "highway")
cway_sev <- osmdata_sp(q1)
q1$bbox
#> [1] "41.00518,-81.887443,41.03993,-81.849498"
Robinlovelace commented 6 years ago

Reproducible example created using reprex: https://github.com/tidyverse/reprex