Learn R Programming

movecost (version 3.0.0)

mc_save: Save and load movecost objects across R sessions

Description

movecost result objects contain terra SpatRaster components, which hold pointers to external memory and therefore cannot be stored with plain saveRDS()/readRDS(). mc_save() wraps all raster components (via terra::wrap()) before serialising; mc_load() restores them. igraph components are serialised natively.

Usage

mc_save(x, file)

mc_load(file)

Value

mc_save() returns file invisibly; mc_load()

returns the restored object.

Arguments

x

a movecost result object.

file

path of the file to write/read (conventionally with extension .rds).

Examples

Run this code
if (FALSE) {
surf <- mc_surface(mc_volc(), funct = "t", move = 8)
f <- tempfile(fileext = ".rds")
mc_save(surf, f)
surf2 <- mc_load(f)
}

Run the code above in your browser using DataLab