powered by
Use wrap to pack a SpatRaster with caching options. See wrap for the general approach that is easier and better to use in most cases.
wrap
This method allows for specifying a folder, or filenames, to cache all sources of a SpatRaster in a specific location (on disk).
# S4 method for SpatRaster wrapCache(x, filename=NULL, path=NULL, overwrite=FALSE, ...)
PackedSpatRaster
SpatRaster
character. A single filename, or one filename per SpatRaster data source. If not NULL, the raster sources are saved in these files
NULL
character. If not NULL, the path where raster sources will be saved. Ignored if filenames is not NULL
Should existing files be overwritten when files or path is not NULL? If this value is not TRUE or FALSE, only files that do not exist are created
files
path
TRUE
FALSE
Additional arguments for writeRaster. Only used for raster sources that are in memory, as other sources are cached by copying the files
writeRaster
wrap, unwrap
unwrap
f <- system.file("ex/elev.tif", package="terra") r <- rast(f) x <- wrapCache(r, path=tempdir()) x
Run the code above in your browser using DataLab