# NOT RUN {
if (requireNamespace("sf", quietly = TRUE)) {
library(sf)
data(cycle_hire_osm)
# or
cycle_hire_osm <- st_read(system.file("shapes/cycle_hire_osm.geojson", package="spData"))
plot(cycle_hire_osm)
}
# Code used to download the data:
# }
# NOT RUN {
library(osmdata)
library(dplyr)
library(sf)
q = add_osm_feature(opq = opq("London"), key = "network", value = "tfl_cycle_hire")
lnd_cycle_hire = osmdata_sf(q)
cycle_hire_osm = lnd_cycle_hire$osm_points
nrow(cycle_hire_osm)
plot(cycle_hire_osm)
cycle_hire_osm = dplyr::select(cycle_hire_osm, osm_id, name, capacity,
cyclestreets_id, description) %>%
mutate(capacity = as.numeric(capacity))
names(cycle_hire_osm)
nrow(cycle_hire_osm)
# }
Run the code above in your browser using DataLab