# NOT RUN {
# Load data
data("berlin")
library(sf)
# Travel path between points
route1 <- osrmRoute(src = apotheke.sf[1, ], dst = apotheke.df[16, ],
returnclass="sf")
# Travel path between points excluding motorways
route2 <- osrmRoute(src = apotheke.sf[1, ], dst = apotheke.df[16, ],
returnclass="sf", exclude = "motorway")
# Display paths
plot(st_geometry(route1))
plot(st_geometry(route2), col = "red", add = TRUE)
plot(st_geometry(apotheke.sf[c(1,16),]), col = "red", pch = 20, add = TRUE)
# Return only duration and distance
route3 <- osrmRoute(src = apotheke.sf[1, ], dst = apotheke.df[16, ],
overview = FALSE)
route3
# }
Run the code above in your browser using DataLab