projectRoads {roads}R Documentation

Project road network

Description

Project road locations based on existing roads, planned landings, and a cost surface that defines the cost of building roads.

Usage

projectRoads(
  landings = NULL,
  cost = NULL,
  roads = NULL,
  roadMethod = "mst",
  plotRoads = FALSE,
  mainTitle = "",
  neighbourhood = "octagon",
  sim = NULL,
  roadsOut = NULL,
  roadsInCost = TRUE,
  ordering = "closest"
)

## S4 method for signature 'ANY,ANY,ANY,ANY,ANY,ANY,ANY,missing'
projectRoads(
  landings = NULL,
  cost = NULL,
  roads = NULL,
  roadMethod = "mst",
  plotRoads = FALSE,
  mainTitle = "",
  neighbourhood = "octagon",
  sim = NULL,
  roadsOut = NULL,
  roadsInCost = TRUE,
  ordering = "closest"
)

## S4 method for signature 'ANY,ANY,ANY,ANY,ANY,ANY,ANY,list'
projectRoads(
  landings = NULL,
  cost = NULL,
  roads = NULL,
  roadMethod = "mst",
  plotRoads = FALSE,
  mainTitle = "",
  neighbourhood = "octagon",
  sim = NULL,
  roadsOut = NULL,
  roadsInCost = TRUE,
  ordering = "closest"
)

Arguments

landings

sf polygons or points, RasterLayer, SpatialPolygons*, SpatialPoints*, matrix, containing features to be connected to the road network. Matrix should contain columns x, y with coordinates, all other columns will be ignored.

cost

RasterLayer. Cost surface where existing roads must be the only cells with a cost of 0. If existing roads do not have 0 cost set roadsInCost = FALSE and they will be burned in.

roads

sf lines, SpatialLines*, RasterLayer. Existing road network.

roadMethod

Character. Options are "mst", "dlcp", "lcp", "snap".

plotRoads

Boolean. Should the resulting road network be plotted. Default FALSE.

mainTitle

Character. A title for the plot

neighbourhood

Character. 'rook','queen', or 'octagon'. The cells that should be considered adjacent. 'octagon' option is a modified version of the queen's 8 cell neighbourhood in which diagonals weights are 2^0.5x higher than horizontal/vertical weights.

sim

list. Returned from a previous iteration of projectRoads. cost, roads, and roadMethod are ignored if a sim list is provided.

roadsOut

Character. Either "raster", "sf" or NULL. If "raster" roads are returned as a raster in the sim list. If "sf" the roads are returned as an sf object which will contain lines if the roads input was sf lines but a geometry collection of lines and points if the roads input was a raster. The points in the geometry collection represent the existing roads while new roads are created as lines. If NULL (default) then the returned roads are sf if the input is sf or Spatial* and raster if the input was a raster.

roadsInCost

Logical. The default is TRUE which means the cost raster is assumed to include existing roads as 0 in its cost surface. If FALSE then the roads will be "burned in" to the cost raster with a cost of 0.

ordering

character. The order in which roads should be built to landings when 'roadMethod = "dlcp"'. Options are "closest" (default) where landings closest to existing roads are accessed first, or "none" where landings are accessed in the order they are provided in.

Details

Four different methods for projecting road networks have been implemented:

Value

a list with components:

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 / least-cost path ("lcp")
# 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, "lcp",
                         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")



[Package roads version 1.1.1 Index]