Skip to contents

Used to ensure that raster data is first loaded into memory so that raster data is saved into the .RData object and not left in a referenced temp file.

Usage

save_raster_rdata(raster, file)

Arguments

raster

RasterLayer; The raster layer to be saved.

file

a (writable binary-mode) connection or the name of the file where the data will be saved (when tilde expansion is done).

Value

None. Saves .RData file to disk.

Details

Using save() to write rasters to .RData files can produce unexpected results. Large RasterLayers are not loaded into memory, but contain a pointer to a file storing the data. save() then only stores a pointer to the temp file holding the data which may not be available later. This function loads on-disk RasterLayers into memory to ensure the data is stored in the .RData file.