Learn R Programming

stplanr (version 0.3.1)

route_dodgr: Route on local data using the dodgr package

Description

Route on local data using the dodgr package

Usage

route_dodgr(from = NULL, to = NULL, l = NULL, net = NULL)

Arguments

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

net

sf object representing the route network

See Also

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

Examples

Run this code
# NOT RUN {
# from <- geo_code("pedallers arms leeds")
from <- c(-1.5327, 53.8006)
# to <- geo_code("gzing")
to <- c(-1.5279, 53.8044)
# next 4 lines recreate `stplanr::osm_net_example`
# pts <- rbind(from, to)
# colnames(pts) <- c("X", "Y")
# net <- dodgr::dodgr_streetnet(pts = rbind(from, to), expand = 0.1)
# osm_net_example <- net[c("highway", "name", "lanes", "maxspeed")]
r <- route_dodgr(from, to, net = osm_net_example)
plot(osm_net_example$geometry)
plot(r$geometry, add = TRUE, col = "red", lwd = 5)
# }

Run the code above in your browser using DataLab