powered by
Run a regression model for each cell of a SpatRaster. The independent variable can either be defined by a vector, or another SpatRaster to make it spatially variable.
# S4 method for SpatRaster,numeric regress(y, x, formula=y~x, na.rm=FALSE, cores=1, filename="", overwrite=FALSE, ...)# S4 method for SpatRaster,SpatRaster regress(y, x, formula=y~x, na.rm=FALSE, cores=1, filename="", overwrite=FALSE, ...)
# S4 method for SpatRaster,SpatRaster regress(y, x, formula=y~x, na.rm=FALSE, cores=1, filename="", overwrite=FALSE, ...)
SpatRaster
SpatRaster or numeric (of the same length as nlyr(x)
nlyr(x)
regression formula in the general form of y ~ x. You can add additional terms such as I(x^2)
y ~ x
I(x^2)
logical. Remove NA values?
positive integer. If cores > 1, a 'parallel' package cluster with that many cores is created and used. You can also supply a cluster object.
cores > 1
character. Output filename
logical. If TRUE, filename is overwritten
TRUE
filename
list with named options for writing files as in writeRaster
writeRaster
s <- rast(system.file("ex/logo.tif", package="terra")) x <- regress(s, 1:nlyr(s))
Run the code above in your browser using DataLab