Learn R Programming

stplanr (version 0.8.2)

route_local: Plan a route with local data

Description

This function returns the shortest path between locations in, or near to, segements on a SpatialLinesNetwork.

Usage

route_local(sln, from, to, l = NULL, ...)

Arguments

sln

The SpatialLinesNetwork or sfNetwork to use.

from

An object representing origins (if lines are provided as the first argument, from is assigned to l)

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

...

Arguments to pass to sum_network_links

See Also

Other routes: line2routeRetry(), line2route(), route_dodgr(), route_osrm(), route_transportapi_public(), route()

Examples

Run this code
# NOT RUN {
from <- c(-1.535181, 53.82534)
to <- c(-1.52446, 53.80949)
sln <- SpatialLinesNetwork(route_network_sf)
r <- route_local(sln, from, to)
plot(sln)
plot(r$geometry, add = TRUE, col = "red", lwd = 5)
plot(cents[c(3, 4), ], add = TRUE)
r2 <- route_local(sln = sln, cents_sf[3, ], cents_sf[4, ])
plot(r2$geometry, add = TRUE, col = "blue", lwd = 3)
l <- flowlines_sf[3:5, ]
r3 <- route_local(l = l, sln = sln)
plot(r2$geometry, add = TRUE, col = "blue", lwd = 3)
# }

Run the code above in your browser using DataLab