mc_save: Save and load movecost objects across R sessions

View source: R/mc_export.R

mc_saveR Documentation

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)

Arguments

x

a movecost result object.

file

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

Value

mc_save() returns file invisibly; mc_load() returns the restored object.

Examples

## Not run: 
surf <- mc_surface(mc_volc(), funct = "t", move = 8)
f <- tempfile(fileext = ".rds")
mc_save(surf, f)
surf2 <- mc_load(f)

## End(Not run)


movecost documentation built on June 16, 2026, 1:06 a.m.