Learn R Programming

terra (version 1.8-5)

serialize: saveRDS and serialize for SpatVector and SpatRaster*

Description

serialize and saveRDS for SpatVector, SpatRaster, SpatRasterDataset and SpatRasterCollection. Note that these objects will first be "packed" with wrap, and after unserialize/readRDS they need to be unpacked with rast or vect.

Extensive use of these functions is not recommended. Especially for SpatRaster it is generally much more efficient to use writeRaster and write, e.g., a GTiff file.

Usage

# S4 method for SpatRaster
saveRDS(object, file="", ascii = FALSE, version = NULL, compress=TRUE, refhook = NULL)

# S4 method for SpatRasterDataset saveRDS(object, file="", ascii = FALSE, version = NULL, compress=TRUE, refhook = NULL)

# S4 method for SpatRasterCollection saveRDS(object, file="", ascii = FALSE, version = NULL, compress=TRUE, refhook = NULL)

# S4 method for SpatVector saveRDS(object, file="", ascii = FALSE, version = NULL, compress=TRUE, refhook = NULL)

# S4 method for SpatRaster serialize(object, connection, ascii = FALSE, xdr = TRUE, version = NULL, refhook = NULL)

# S4 method for SpatVector serialize(object, connection, ascii = FALSE, xdr = TRUE, version = NULL, refhook = NULL)

Value

Packed* object

Arguments

object

SpatVector, SpatRaster, SpatRasterDataset or SpatRasterCollection

file

file name to save object to

connection

see serialize

ascii

see serialize or saveRDS

version

see serialize or saveRDS

compress

see serialize or saveRDS

refhook

see serialize or saveRDS

xdr

see serialize or saveRDS

Examples

Run this code
f <- system.file("ex/lux.shp", package="terra")
v <- vect(f)
p <- serialize(v, NULL)
head(p)
x <- unserialize(p)
x

Run the code above in your browser using DataLab