Slot map
inside PCA result is a RasterBrick
:
library(RStoolbox)
library(ggplot2)
library(reshape2)
data(rlogo)
set.seed(25)
rpc <- rasterPCA(rlogo)
class(rpc$map)
[1] "RasterBrick"
attr(,"package")
[1] "raster"
You can save this slot as a raster with raster
package:
library(raster)
writeRaster(rpc$map, "rpc.tif")
You can set bylayer = FALSE
if you want a multi-layer raster as output, default is TRUE
.
Also, read function description:
Principal Component Analysis for Rasters
Description
Calculates R-mode PCA for RasterBricks or RasterStacks and returns a RasterBrick with multiple layers of PCA scores.