Rasters are sometimes file-based, so the normal save and copy and assign mechanisms in R don't work for saving, copying and assigning. This function creates an explicit file copy of the file that is backing the raster, and changes the pointer (i.e., filename(object)) so that it is pointing to the new file.

.prepareFileBackedRaster(
  obj,
  repoDir = NULL,
  overwrite = FALSE,
  drv = getDrv(getOption("reproducible.drv", NULL)),
  conn = getOption("reproducible.conn", NULL),
  ...
)

Arguments

obj

The raster object to save to the repository.

repoDir

Character denoting an existing directory in which an artifact will be saved.

overwrite

Logical. Should the raster be saved to disk, overwriting existing file.

drv

if using a database backend, drv must be an object that inherits from DBIDriver e.g., from package RSQLite, e.g., SQLite

conn

an optional DBIConnection object, as returned by dbConnect().

...

Not used

Value

A raster object and its newly located file backing. Note that if this is a legitimate Cache repository, the new location will be a subdirectory called rasters/ of repoDir/. If this is not a repository, the new location will be within repoDir.

Author

Eliot McIntire