Learn R Programming

RStoolbox (version 0.1.1)

saveRSTBX: Save and Read RStoolbox Classification Results

Description

Saves objects of classes unsuperClass, superClass, rasterPCA and fCover to file. Useful to archive the fitted models.

Usage

saveRSTBX(x, filename, format = "raster", ...)

readRSTBX(filename)

Arguments

x
RStoolbox object of classes c("fCover", "rasterPCA", "superClass", "unsuperClass")
filename
Character. Path and filename. Any file extension will be ignored.
format
Character. Driver to use for the raster file
...
further arguments passed to writeRaster

Value

  • The output of writeRSTBX will be at least two files written to disk: a) an .rds file containing the object itself and b) the raster file (depending on the driver you choose this can be more than two files).

Functions

  • readRSTBX:

Examples

Run this code
input <- brick(system.file("external/rlogo.grd", package="raster"))
## Create filename
file  <- paste0(tempdir(), "/test", runif(1))
## Run PCA
rpc   <- rasterPCA(input, filename = file, nSample = 100)
## Save object
saveRSTBX(rpc, filename=file)
## Which files were written?
list.files(tempdir(), pattern = basename(file))
## Re-read files
re_rpc <- readRSTBX(file)
## Compare
all.equal(re_rpc, rpc)
file.remove(file)

Run the code above in your browser using DataLab