# NOT RUN {
data(routes_fast)
rnet <- overline(routes_fast, attrib = "length")
SLN <- SpatialLinesNetwork(rnet)
class(SLN)
weightfield(SLN) # field used to determine shortest path
plot(SLN)
from_id = 1
to_id = 50
points(sln2points(SLN)[from_id,], cex = 5)
points(sln2points(SLN)[to_id,], cex = 5)
shortpath <- sum_network_routes(SLN, from_id, to_id, sumvars = "length")
plot(shortpath, col = "red", lwd = 4, add = TRUE)
to_id = 35
points(sln2points(SLN)[to_id,], cex = 5)
shortpath <- sum_network_routes(SLN, from_id, to_id, sumvars = "length")
plot(shortpath, col = "red", lwd = 4, add = TRUE)
# }
Run the code above in your browser using DataLab