Using the osmr or stplanr packages I can easily get the fastest route between two points using OSMR
library(osrm) library(stplanr) library(sf) path <- osrmRoute(src = c("Buckingham", 0.140634, 51.501476), dst = c("Pauls", -0.098362, 51.513870)) %>% st_as_sf(coords = c("lat", "lon"), remove = FALSE) plot(path$geometry) path2 <- stplanr::route_osrm(from = c(0.140634, 51.501476), to = c(-0.098362, 51.513870)) %>% st_as_sf() plot(path2$geometry)
(which as far as I'm aware fundamentally do the same thing- I don't have a preference on library/function)
However, let's say I'm looking for the n fastest routes (for completeness in this example I'll say n=3). Is there a way to sample osrm to do this? (manually I assume you could program the function to iterate through the fastest routes excluding road by road but seems excessive?)
stplanr::route_osrm has an 'alt' argument that is listed as:
Boolean value to return alternative routes (default = TRUE).'
but I can't seem to find what that actually means.