Make a RasterLayer with interpolated values using a fitted model object of classes such as "gstat" (gstat package) or "Krige" (fields package). That is, these are models that have location ("x" and "y", or "longitude" and "latitude") as independent variables. If x and y are the only independent variables provide an empty (no associated data in memory or on file) SpatRaster for which you want predictions. If there are more spatial predictor variables provide these as a Raster* object in the first argument of the function. If you do not have x and y locations as implicit predictors in your model you should use predict
instead.
# S4 method for SpatRaster
interpolate(object, model, fun=predict, ...,
xyNames=c("x", "y"), factors=NULL, const=NULL, index = NULL,
na.rm=FALSE, filename="", overwrite=FALSE, wopt=list())
SpatRaster
model object
function. Default value is "predict", but can be replaced with e.g. "predict.se" (depending on the class of the model object)
additional arguments passed to fun
character. variable names that the model uses for the spatial coordinates. E.g., c("longitude", "latitude")
list with levels for factor variables. The list elements should be named with names that correspond to names in object
such that they can be matched. This argument may be omitted for many models as the predict function will extract the levels from the model
object
data.frame. Can be used to add a constant for which there is no Raster object for model predictions. This is particularly useful if the constant is a character-like factor value
positive integer or NULL. Allows for selecting of the variable returned if the model returns multiple variables
logical. If TRUE
, cells with NA
values in the predictors are removed from the computation. This option prevents errors with models that cannot handle NA
values. In most other cases this will not affect the output. An exception is when predicting with a model that returns predicted values even if some (or all!) variables are NA
character. Output filename. Optional
logical. If TRUE
, filename
is overwritten
list. Options for writing files as in writeRaster
SpatRaster