This function allows to use a raster as data to make predictions from a
variety of tidymodels objects, such as simple_ensemble or
stacks::stacks
Usage
predict_raster(object, raster, ...)
# Default S3 method
predict_raster(object, raster, filename = "", n = 4, ...)Arguments
- object
the
tidymodelsobject of interest- raster
the
terra::SpatRasterorstarswith the input data. It has to include levels with the same names as the variables used inobject- ...
parameters to be passed to the standard
predict()function for the appropriate object type (e.g.metric_thresh,class_threshorfun). See the documentation of the relevantpredict()method for possible parameters (e.g.predict.simple_ensemble()).- filename
the name of the output file raster file; this is only needed to save large rasters, and can be left blank for rasters that can be kept in memory.
- n
positive integer indicating how many copies the data may be in memory at any point in time (it defaults to 4). This is used to determine whether rasters can be processed in one go, or in chunks. If you get an out of memory error, increase
n. Seeterra::writeStart()for more details.
Value
a terra::SpatRaster (or stars if that is the input) with the
predictions
