replace_values {leastcostpath} | R Documentation |
replace values with values from another object
Description
Replace values of conductanceMatrix
x with the values of conductanceMatrix
y that coincide with the supplied sf object
Usage
replace_values(x, y, sf)
Arguments
x |
|
y |
|
sf |
|
Details
The values of conductanceMatrix
x are replaced with the values from conductanceMatrix
y that coincide with the supplied sf object
Value
conductanceMatrix
Author(s)
Joseph Lewis
Examples
r <- terra::rast(system.file("extdata/SICILY_1000m.tif", package="leastcostpath"))
x <- create_slope_cs(x = r, cost_function = "tobler", neighbours = 4)
locs <- sf::st_sf(geometry = sf::st_sfc(
sf::st_point(c(960745, 4166836)),
crs = terra::crs(r)))
locs <- sf::st_buffer(x = locs, dist = 25000)
y <- update_values(x = x, sf = locs, FUN = function(j) { j + 10})
output <- replace_values(x = x, y = y, sf = locs)
identical(y$conductanceMatrix, output$conductanceMatrix)
[Package leastcostpath version 2.0.12 Index]