Learn R Programming

stplanr (version 0.2.8)

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 to use.

from

Text string or coordinates (a numeric vector of length = 2 representing latitude and longitude) representing a point on Earth.

to

Text string or coordinates (a numeric vector of length = 2 representing latitude and longitude) representing a point on Earth. This represents the destination of the trip.

l

Only needed if from and to are empty, in which case this should be a spatial object representing desire lines

See Also

Other routes: line2routeRetry, line2route, nearest2spdf, route_cyclestreet, route_dodgr, route_graphhopper, route_osrm, route_transportapi_public, route, viaroute2sldf, viaroute

Examples

Run this code
# NOT RUN {
# from <- matrix(stplanr::geo_code("pedallers arms leeds"), ncol = 2)
from <-c(-1.5327711, 53.8006988)
# to <- matrix(stplanr::geo_code("gzing"), ncol = 2)
to <- c(-1.527937, 53.8044309)
sln <- SpatialLinesNetwork(osm_net_example)
# }
# NOT RUN {
r <- route_local(sln, from, to)
plot(r)
# todo: next code chunk is not currently working:
r2 <- route_local(sln = sln, cents_sf[5, ], cents_sf[6, ])
plot(r2)
r_many <- line2route(flowlines_sf[2:9, ], route_local, sln = sln)
plot(cents)
plot(sln@sl, add = TRUE)
plot(r_many, add = TRUE)
# }

Run the code above in your browser using DataLab