This function processes a SpatRaster
object or a file path to it, ensuring
the raster is loaded and unpacked if necessary. It converts raster objects
from the raster
package to SpatRaster
objects. The function ensures that
the SpatRaster
object is read from memory, not from file.
Details
The function handles various types of input:
If a file path is provided, it attempts to load the raster using
terra::rast()
.If the input is a packed
SpatRaster
, it unpacks the raster usingterra::unwrap()
.If the input is a raster object from the
raster
package, it is converted toSpatRaster
.