Learn R Programming

terra (version 1.9-25)

readwrite: Read from, or write to, file

Description

Methods to read from or write chunks of values to or from a file. These are low level methods for programmers. Use writeRaster if you want to save an entire SpatRaster to file in one step. It is much easier to use.

To write chunks, begin by opening a file with writeStart, then write values to it in chunks using the list that is returned by writeStart. When writing is done, close the file with writeStop.

blocks only returns chunk size information. This can be useful when reading, but not writing, raster data.

Usage

# S4 method for SpatRaster
readStart(x)

# S4 method for SpatRaster readStop(x)

# S4 method for SpatRaster readValues(x, row=1, nrows=nrow(x), col=1, ncols=ncol(x), mat=FALSE, dataframe=FALSE, ...)

# S4 method for SpatRaster,character writeStart(x, filename="", overwrite=FALSE, n=4, sources="", ...)

# S4 method for SpatRaster writeStop(x)

# S4 method for SpatRaster,vector writeValues(x, v, start, nrows)

# S4 method for SpatRaster blocks(x, n=4)

fileBlocksize(x)

Arguments

Value

readValues returns a vector, matrix, or data.frame

writeStart returns a list that can be used for processing the file in chunks.

The other methods invisibly return a logical value indicating whether they were successful or not. Their purpose is the side-effect of opening or closing files.