library(terra)
data(wigger)
r1 <- rast(system.file("extdata/landcover.tif", package = "rivnet"))
# legend: 1-urban; 2-agriculture; 3-forest; 4-improductive
r.exp <- rast_riverweight(r1, wigger)
plot(r.exp)
# \donttest{
# unweighted denominator
r.unweighted <- rast_riverweight(r1, wigger,
weightDen = list(func = "unweighted"))
# alternative distance decay functions (with same dist50)
# these take more time than the default func = "exponential"
r.cau <- rast_riverweight(r1, wigger,
weightNum = list(func = "cauchy"))
r.lin <- rast_riverweight(r1, wigger,
weightNum = list(func = "linear"))
r.pow <- rast_riverweight(r1, wigger,
weightNum = list(func = "power"))
# ignore distances on the river network
r.exp_S <- rast_riverweight(r1, wigger,
weightNum = list(stream = TRUE))
# include flow accumulation in the weight
r.exp_FA <- rast_riverweight(r1, wigger,
weightNum = list(FA = TRUE))
# use Euclidean distances (takes more time)
# Euclidean distance from source to target
r.dO <- rast_riverweight(r1, wigger,
weightNum = list(mode = "euclidean"))
# Euclidean distance from source to river network
r.dOS <- rast_riverweight(r1, wigger,
weightNum = list(mode = "euclidean",
stream = TRUE))
# specify exponential decay parameter in different ways
r.exp1 <- rast_riverweight(r1, wigger,
weightNum = list(dist50 = 1000*log(2)))
r.exp2 <- rast_riverweight(r1, wigger,
weightNum = list(distExponential = 1000))
identical(r.exp1, r.exp2)
# }
Run the code above in your browser using DataLab