Learn R Programming

terra (version 1.7-83)

wrapCache: SpatRaster wrap with caching options

Description

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.

This method allows for specifying a folder, or filenames, to cache all sources of a SpatRaster in a specific location (on disk).

Usage

# S4 method for SpatRaster
wrapCache(x, filename=NULL, path=NULL, overwrite=FALSE, ...)

Value

PackedSpatRaster

Arguments

x

SpatRaster

filename

character. A single filename, or one filename per SpatRaster data source. If not NULL, the raster sources are saved in these files

path

character. If not NULL, the path where raster sources will be saved. Ignored if filenames is not NULL

overwrite

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

...

Additional arguments for writeRaster. Only used for raster sources that are in memory, as other sources are cached by copying the files

See Also

wrap, unwrap

Examples

Run this code
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