# NOT RUN {
SLN <- SpatialLinesNetwork(route_network)
class(SLN)
weightfield(SLN) # field used to determine shortest path
plot(SLN)
# }
# NOT RUN {
points(sln2points(SLN)[1, ], cex = 5)
points(sln2points(SLN)[50, ], cex = 5)
shortpath <- sum_network_routes(SLN, 1, 50, sumvars = "length")
plot(shortpath, col = "red", lwd = 4, add = TRUE)
points(sln2points(SLN)[35, ], cex = 5)
shortpath <- sum_network_routes(SLN, 1, 35, sumvars = "length")
plot(shortpath, col = "red", lwd = 4, add = TRUE)
library(sf)
SLN_sf <- SpatialLinesNetwork(route_network_sf)
plot(SLN_sf)
shortpath <- sum_network_routes(SLN_sf, 1, 50, sumvars = "length")
plot(shortpath$geometry, col = "red", lwd = 4, add = TRUE)
# }
Run the code above in your browser using DataLab