RStoolbox (version 0.2.6)

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

  • saveRSTBX: Save RStoolbox object to file

  • readRSTBX: Read files saved with saveRSTBX

Examples

Run this code
# NOT RUN {
input <- brick(system.file("external/rlogo.grd", package="raster"))
## Create filename
file  <- paste0(tempdir(), "/test", runif(1))
## Run PCA
rpc   <- rasterPCA(input, 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)
## Remove files 
file.remove(list.files(tempdir(), pattern = basename(file), full = TRUE))
# }

Run the code above in your browser using DataCamp Workspace