Learn R Programming

landmap (version 0.0.13)

spc,SpatialPixelsDataFrame-method: Generate Principal Components using SpatialPixelsDataFrame object

Description

Combines the stats::prcomp method and predicts a list principal components for an object of type "SpatialPixelsDataFrame".

Usage

# S4 method for SpatialPixelsDataFrame
spc(obj, formulaString, scale. = TRUE, silent = FALSE)

Arguments

obj

SpatialPixelsDataFrame.

formulaString

optional model definition.

scale.

scale all numbers.

silent

silent output.

Value

Object of class SpatialComponents. List of grids with generic names PC1,…,PCp, where p is the total number of input grids.

Examples

Run this code
# NOT RUN {
if(requireNamespace("plotKML", quietly = TRUE)){
library(sp)
library(plotKML)
pal = rev(rainbow(65)[1:48])
data(eberg_grid)
gridded(eberg_grid) <- ~x+y
proj4string(eberg_grid) <- CRS("+init=epsg:31467")
formulaString <- ~ PRMGEO6+DEMSRT6+TWISRT6+TIRAST6
eberg_spc <- spc(eberg_grid, formulaString)
names(eberg_spc@predicted) # 11 components on the end;
## plot maps:
rd = range(eberg_spc@predicted@data[,1], na.rm=TRUE)
sq = seq(rd[1], rd[2], length.out=48)
spplot(eberg_spc@predicted[1:4], at=sq, col.regions=pal)
}
# }

Run the code above in your browser using DataLab