R/SpatialLinesNetwork.R
sum_network_routes.RdSummarise shortest path between nodes on network
sum_network_routes( sln, start, end, sumvars = weightfield(sln), combinations = FALSE )
| sln | The SpatialLinesNetwork to use. |
|---|---|
| start | Integer of node indices where route ends. |
| end | Integer of node indices where route ends. |
| sumvars | Character vector of variables for which to calculate
summary statistics. The default value is |
| combinations | Boolean value indicating if all combinations of start and ends should be calculated. If TRUE then every start Node ID will be routed to every end Node ID. This is faster than passing every combination to start and end. Default is FALSE. |
Find the shortest path on the network between specified nodes and returns a SpatialLinesdataFrame containing the path(s) and summary statistics of each one.
The start and end arguments must be integers representing the node index.
To find which node is closes to a geographic point, use find_nearest_node()
Other rnet:
SpatialLinesNetwork,
calc_catchment_sum(),
calc_catchment(),
calc_moving_catchment(),
calc_network_catchment(),
find_network_nodes(),
gsection(),
islines(),
lineLabels(),
overline_spatial(),
overline(),
plot,SpatialLinesNetwork,ANY-method,
plot,sfNetwork,ANY-method,
rnet_breakup_vertices(),
rnet_group(),
sln2points(),
sum_network_links()
#> Warning: CRS object has comment, which is lost in output#> Warning: CRS object has comment, which is lost in output#> Warning: CRS object has comment, which is lost in output#> Warning: CRS object has comment, which is lost in output#> Warning: CRS object has comment, which is lost in output#> Warning: CRS object has comment, which is lost in output#> Warning: CRS object has comment, which is lost in output#> Warning: CRS object has comment, which is lost in output#> Warning: CRS object has comment, which is lost in output#> Warning: CRS object has comment, which is lost in output#> Warning: CRS object has comment, which is lost in output#> Warning: CRS object has comment, which is lost in output#> Warning: CRS object has comment, which is lost in output#> Warning: CRS object has comment, which is lost in output#> Warning: CRS object has comment, which is lost in output#> Warning: CRS object has comment, which is lost in output#> Warning: CRS object has comment, which is lost in output#> Warning: CRS object has comment, which is lost in output#> Warning: CRS object has comment, which is lost in output#> Warning: CRS object has comment, which is lost in output#> Warning: CRS object has comment, which is lost in output#> Warning: CRS object has comment, which is lost in output#> Warning: CRS object has comment, which is lost in output#> Warning: CRS object has comment, which is lost in output#> Warning: CRS object has comment, which is lost in output#> Warning: CRS object has comment, which is lost in output#> Warning: CRS object has comment, which is lost in output#> Warning: CRS object has comment, which is lost in output#> Warning: CRS object has comment, which is lost in output#> Warning: CRS object has comment, which is lost in output#> Warning: CRS object has comment, which is lost in output#> Warning: CRS object has comment, which is lost in output#> Warning: CRS object has comment, which is lost in output#> Warning: CRS object has comment, which is lost in output#> Warning: CRS object has comment, which is lost in output#> Warning: CRS object has comment, which is lost in output#> Warning: CRS object has comment, which is lost in output#> Warning: CRS object has comment, which is lost in output#> Warning: CRS object has comment, which is lost in output#> Warning: CRS object has comment, which is lost in output#> Warning: CRS object has comment, which is lost in output#> Warning: CRS object has comment, which is lost in output#> Warning: CRS object has comment, which is lost in output#> Warning: CRS object has comment, which is lost in output#> Warning: CRS object has comment, which is lost in output#> Warning: CRS object has comment, which is lost in output#> Warning: CRS object has comment, which is lost in output#> Warning: CRS object has comment, which is lost in output#> Warning: CRS object has comment, which is lost in output#> Warning: CRS object has comment, which is lost in output#> Warning: CRS object has comment, which is lost in output#> Warning: CRS object has comment, which is lost in output#> Warning: CRS object has comment, which is lost in output#> Warning: CRS object has comment, which is lost in output#> Warning: CRS object has comment, which is lost in output#> Warning: CRS object has comment, which is lost in output#> Warning: CRS object has comment, which is lost in output#> Warning: CRS object has comment, which is lost in output#> Warning: CRS object has comment, which is lost in output#> Warning: CRS object has comment, which is lost in output#> Warning: CRS object has comment, which is lost in output#> Warning: CRS object has comment, which is lost in output#> Warning: CRS object has comment, which is lost in output#> Warning: CRS object has comment, which is lost in output#> Warning: CRS object has comment, which is lost in output#> Warning: CRS object has comment, which is lost in output#> Warning: CRS object has comment, which is lost in output#> Warning: CRS object has comment, which is lost in output#> Warning: CRS object has comment, which is lost in output#> Warning: CRS object has comment, which is lost in output#> Warning: CRS object has comment, which is lost in output#> Warning: CRS object has comment, which is lost in output#> Warning: CRS object has comment, which is lost in output#> Warning: CRS object has comment, which is lost in output#> Warning: CRS object has comment, which is lost in output#> Warning: CRS object has comment, which is lost in output#> Warning: CRS object has comment, which is lost in output#> Warning: CRS object has comment, which is lost in output#> Warning: CRS object has comment, which is lost in output#> Warning: CRS object has comment, which is lost in output#> [1] "length"shortpath <- sum_network_routes(sln, start = 1, end = 50, sumvars = "length") plot(shortpath, col = "red", lwd = 4)# with sf objects sln <- SpatialLinesNetwork(route_network_sf) weightfield(sln) # field used to determine shortest path#> [1] "length"shortpath <- sum_network_routes(sln, start = 1, end = 50, sumvars = "length") plot(sf::st_geometry(shortpath), col = "red", lwd = 4)#> xmin ymin xmax ymax #> -1.550964 53.802478 -1.510987 53.830414nodes <- find_network_nodes(sln, rbind(start_coords, end_coords)) shortpath <- sum_network_routes(sln, nodes[1], nodes[2]) plot(sf::st_geometry(shortpath), col = "red", lwd = 3, add = TRUE)