# NOT RUN {
# Load data
data("berlin")
# Get a trip with a id lat lon data.frame
trips <- osrmTrip(loc = apotheke.df)
# Display the trip
library(sp)
plot(trips[[1]]$trip, col = "black", lwd = 4)
plot(trips[[1]]$trip, col = c("red", "white"), lwd = 1, add=T)
points(apotheke.df[, 2:3], pch = 21, bg = "red", cex = 1)
# Map
if(require("cartography")){
osm <- getTiles(x = trips[[1]]$trip, crop = TRUE,
type = "cartolight", zoom = 11)
tilesLayer(x = osm)
plot(trips[[1]]$trip, col = "black", lwd = 4, add=T)
plot(trips[[1]]$trip, col = c("red", "white"), lwd = 1, add=T)
points(apotheke.df[, 2:3], pch = 21, bg = "red", cex = 1)
}
# Get a trip with a SpatialPointsDataFrame
trips <- osrmTrip(loc = apotheke.sp[1:10,])
# Map
if(require("cartography")){
osm <- getTiles(x = trips[[1]]$trip, crop = TRUE,
type = "cartolight", zoom = 11)
tilesLayer(x = osm)
plot(trips[[1]]$trip, col = "black", lwd = 4, add=T)
plot(trips[[1]]$trip, col = c("red", "white"), lwd = 1, add=T)
plot(apotheke.sp[1:10,], pch = 21, bg = "red", cex = 1, add=T)
}
# }
Run the code above in your browser using DataLab