Learn R Programming

GSIF (version 0.3-1)

spc: Derive Spatial Predictive Components

Description

Derives Spatial Predictive Components for a given set of covariates. It wraps the stats::prcomp method and predicts a list principal components for an object of type "SpatialPixelsDataFrame".

Usage

## S3 method for class 'SpatialPixelsDataFrame,formula':
spc(obj, formulaString, scale. = TRUE, 
      silent = FALSE, \dots)
## S3 method for class 'list,list':
spc(obj, formulaString, scale. = TRUE, 
      silent = FALSE, \dots)

Arguments

obj
object of class "SpatialPixelsDataFrame" (must contain at least two grids) or a list of objects of type "SpatialPixelsDataFrame"
formulaString
object of class "formula" or a list of formulas
scale.
object of class "logical"; specifies whether covariates need to be scaled
silent
object of class "logical"; specifies whether to print the progress
...
additional arguments that can be passed to stats::prcomp

Value

  • spc returns an object of type "SpatialComponents". This is a list of grids with generic names PC1,...,PCp, where p is the total number of input grids.

See Also

stats::prcomp, SpatialComponents-class

Examples

Run this code
# load data:
library(plotKML)
library(sp)

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