Takes origins and destinations, finds the optimal routes between them and returns the result as a spatial (sf or sp) object. The definition of optimal depends on the routing function used
route( from = NULL, to = NULL, l = NULL, route_fun = cyclestreets::journey, n_print = 10, list_output = FALSE, cl = NULL, ... )
| from | An object representing origins
(if lines are provided as the first argument, from is assigned to |
|---|---|
| to | An object representing destinations |
| l | Only needed if from and to are empty, in which case this should be a spatial object representing desire lines |
| route_fun | A routing function to be used for converting the straight lines to routes
|
| n_print | A number specifying how frequently progress updates should be shown |
| list_output | If FALSE (default) assumes spatial (linestring) object output. Set to TRUE to save output as a list. |
| cl | Cluster |
| ... | Arguments passed to the routing function, e.g. |
Other routes:
line2routeRetry(),
line2route(),
route_dodgr(),
route_local(),
route_transportapi_public()
#>#>r_osrm <- route( from = c(-0.11, 51.514), to = c(-0.10, 51.506), route_fun = osrmRoute, returnclass = "sf" )#>r <- overline(routes_fast_sf[2:5, ], "length") l <- od2line(od_data_sample[2:5, 1:3], cents_sf) sln <- stplanr::SpatialLinesNetwork(r) # calculate shortest paths plot(sln)#>