# \donttest{
library(terra)
elev <- rast(system.file("extdata/elev.tif", package="spatialEco"))
# calculate tpi and plot
tpi7 <- tpi(elev, scale=7)
tpi025 <- tpi(elev, win = "circle", scale=2500)
tpi025.zc <- tpi(elev, win = "circle", scale=2500,
zero.correct = TRUE)
opar <- par(no.readonly=TRUE)
par(mfrow=c(2,2))
plot(elev, main="original raster")
plot(tpi7, main="tpi 7x7")
plot(tpi025, main="tpi Circular window d=2500m")
plot(tpi025, main="tpi Circular window d=2500m, zero correct")
par(opar)
# }
Run the code above in your browser using DataLab