if (FALSE) {
# Load data
library(sf)
apotheke.sf <- st_read(system.file("gpkg/apotheke.gpkg", package = "osrm"),
quiet = TRUE)
# Get isochones with lon/lat coordinates
iso <- osrmIsochrone(loc = c(13.43,52.47), breaks = seq(0,14,2),
returnclass="sf")
plot(st_geometry(iso), col = c('grey80','grey60','grey50',
'grey40','grey30','grey20'))
# Map
if(require("mapsf")){
breaks <- sort(c(unique(iso$min), max(iso$max)))
mapsf::mf_map(x = iso, var = "center", type = "choro",
breaks = breaks, pal = "Greens",
border = NA, leg_pos = "topleft",
leg_frame = TRUE, leg_title = "Isochrones\n(min)")
}
# Get isochones with an sf POINT
iso2 <- osrmIsochrone(loc = apotheke.sf[10,], returnclass="sf",
breaks = seq(from = 0, to = 16, by = 2))
# Map
if(require("mapsf")){
breaks2 <- sort(c(unique(iso2$min), max(iso2$max)))
mapsf::mf_map(x = iso2, var = "center", type = "choro",
breaks = breaks2, pal = "Blues",
border = NA, leg_pos = "topleft", leg_val_rnd = 0,
leg_frame = TRUE, leg_title = "Isochrones\n(min)")
}
}
Run the code above in your browser using DataLab