projectRoads {roads} | R Documentation |
Project road network
Description
Project a road network that links target landings to existing roads. For all
methods except "snap"
, a weightRaster
and weightFunction
together
determine the cost to build a road between two adjacent raster cells.
Usage
projectRoads(
landings = NULL,
weightRaster = NULL,
roads = NULL,
roadMethod = "ilcp",
plotRoads = FALSE,
mainTitle = "",
neighbourhood = "octagon",
weightFunction = simpleCostFn,
sim = NULL,
roadsOut = NULL,
roadsInWeight = TRUE,
ordering = "closest",
roadsConnected = FALSE,
...
)
## S4 method for signature 'ANY,ANY,ANY,ANY,ANY,ANY,ANY,ANY,missing'
projectRoads(
landings = NULL,
weightRaster = NULL,
roads = NULL,
roadMethod = "ilcp",
plotRoads = FALSE,
mainTitle = "",
neighbourhood = "octagon",
weightFunction = simpleCostFn,
sim = NULL,
roadsOut = NULL,
roadsInWeight = TRUE,
ordering = "closest",
roadsConnected = FALSE,
...
)
## S4 method for signature 'ANY,ANY,ANY,ANY,ANY,ANY,ANY,ANY,list'
projectRoads(
landings = NULL,
weightRaster = NULL,
roads = NULL,
roadMethod = "ilcp",
plotRoads = FALSE,
mainTitle = "",
neighbourhood = "octagon",
weightFunction = simpleCostFn,
sim = NULL,
roadsOut = NULL,
roadsInWeight = TRUE,
ordering = "closest",
roadsConnected = FALSE,
...
)
Arguments
landings |
sf polygons or points, |
weightRaster |
|
roads |
sf lines, |
roadMethod |
Character. Options are |
plotRoads |
Boolean. Should the resulting road network be plotted.
Default |
mainTitle |
Character. A title for the plot. |
neighbourhood |
Character. |
weightFunction |
function. Method for calculating the weight of an edge
between two nodes from the value of the |
sim |
list. Returned from a previous iteration of |
roadsOut |
Character. Either |
roadsInWeight |
Logical. If |
ordering |
character. The order in which landings are processed when
|
roadsConnected |
Logical. Are all roads fully connected? If |
... |
Optional additional arguments to |
Details
Four road network projection methods are:
-
"lcp"
: The Least Cost Path method connects each landing to the closest road with a least cost path, without reference to other landings. -
"ilcp"
: The Iterative Least Cost Path method iteratively connects each landing to the closest road with a least cost path, so that the path to each successive landing can include roads constructed to access previous landings. The sequence of landings is determined byordering
and is "closest" by default. The alternative "none" option processes landings in the order supplied by the user. -
"mst"
: The Minimum Spanning Tree method connects landings to the existing road with a minimum spanning tree that does not require users to specify the order in which landings are processed. -
"snap"
: Connects each landing to the closest (by Euclidean distance) road without, reference to the weights or other landings.
Value
a list with components:
roads: the projected road network, including new and input roads.
weightRaster: the updated
weightRaster
in which new and old roads have value 0.roadMethod: the road simulation method used.
landings: the landings used in the simulation.
g: the graph that describes the cost of paths between each cell in the updated
weightRaster
. Edges between vertices connected by new roads have weight 0.g
can be used to avoid the cost of rebuilding the graph in a simulation with multiple time steps.
Examples
CLUSexample <- prepExData(CLUSexample)
doPlots <- interactive()
projectRoads(CLUSexample$landings, CLUSexample$cost, CLUSexample$roads,
"lcp", plotRoads = doPlots, mainTitle = "CLUSexample")
# More realistic examples that take longer to run
demoScen <- prepExData(demoScen)
### using: scenario 1 / sf landings / iterative least-cost path ("ilcp")
# demo scenario 1
scen <- demoScen[[1]]
# landing set 1 of scenario 1:
land.pnts <- scen$landings.points[scen$landings.points$set==1,]
prRes <- projectRoads(land.pnts, scen$cost.rast, scen$road.line, "ilcp",
plotRoads = doPlots, mainTitle = "Scen 1: SPDF-LCP")
### using: scenario 1 / `SpatRaster` landings / minimum spanning tree ("mst")
# demo scenario 1
scen <- demoScen[[1]]
# the RasterLayer version of landing set 1 of scenario 1:
land.rLyr <- scen$landings.stack[[1]]
prRes <- projectRoads(land.rLyr, scen$cost.rast, scen$road.line, "mst",
plotRoads = doPlots, mainTitle = "Scen 1: Raster-MST")
### using: scenario 2 / matrix landings raster roads / snapping ("snap")
# demo scenario 2
scen <- demoScen[[2]]
# landing set 5 of scenario 2, as matrix:
land.mat <- scen$landings.points[scen$landings.points$set==5,] |>
sf::st_coordinates()
prRes <- projectRoads(land.mat, scen$cost.rast, scen$road.rast, "snap",
plotRoads = doPlots, mainTitle = "Scen 2: Matrix-Snap")
## using scenario 7 / Polygon landings raster / minimum spanning tree
# demo scenario 7
scen <- demoScen[[7]]
# rasterize polygonal landings of demo scenario 7:
land.polyR <- terra::rasterize(scen$landings.poly, scen$cost.rast)
prRes <- projectRoads(land.polyR, scen$cost.rast, scen$road.rast, "mst",
plotRoads = doPlots, mainTitle = "Scen 7: PolyRast-MST")