Learn R Programming

terra (version 1.8-5)

toMemory: Read all cell values into memory

Description

Reads all cell values of a SpatRaster or SpatRasterDataset into memory.

Using this method is discouraged as it is not necessary for processing the data and may lead to excessive memory use that will slow down your computer or worse. It cannot be used for SpatRasters that are based on very large files.

The method may be useful if a relatively small dataset is used repeatedly, such that efficiency gains are made because the values only need to be read from disk once.

Usage

# S4 method for SpatRaster
toMemory(x)

# S4 method for SpatRasterDataset toMemory(x)

Value

Same as x

Arguments

x

SpatRaster or SpatRasterDataset

See Also

values, as.data.frame, readValues

Examples

Run this code
f <- system.file("ex/elev.tif", package="terra")
r <- rast(f)
sources(r)
inMemory(r)
x <- toMemory(r)
inMemory(x)

Run the code above in your browser using DataLab