Learn R Programming

rsMove (version 0.1)

modelApply: modelApply

Description

Apply a model or an ensemble of models to raster data.

Usage

modelApply(model, img)

Arguments

model

List object as provided by moveModel().

img

Object of class RasterLayer, RasterStack or RasterBrick.

Value

A Raster.

Details

The function uses the output of moveModel(). If this contains a list of models from multiple runs, the function creates a stack of predictions and summarizes it on a pixel-by-pixel basis using a weighted mean. The weights are defined by the average performance for presence and background samples in each iteration.

See Also

segRaster moveModel

Examples

Run this code
# NOT RUN {
 
 require(rgdal)
 require(raster)
 require(sp)
 
 # read example data
 file <- system.file('extdata', 'konstanz_20130805-20130811.shp', package="rsMove")
 moveData <- shapefile(file)

 # extract samples
 ot = as.Date(moveData@data$date)
 samples <- sampleMove(xy=moveData, ot=ot, error=10, method='m')

 # read remote sensing data
 file <- list.files(system.file('extdata', '', package="rsMove"), 'tc.*tif', full.names=TRUE)
 rsStk <- stack(file)
 
 # retrieve remote sensing data for samples
 rsQuery <- dataQuery(xy=samples,img=rsStk, rd=TRUE)
 
 # identify unique sample regions
 label <- labelSample(xy=rsQuery, rad=90, npx=1, pxr=rsStack)
 
 # select background samples
 ind <- which(label>0) # selected samples
 bSamples <- backSample(xy=moveData[ind,], rid=label[ind], img=rsStk, method='pca')
 
 # derive model predictions
 p.model <- moveModel(pxy=rsQuery, axy=bSamples, label=label)
 
 # derive prediction from model ensemble
 prob <- modelApply(p.model, rsStack)
 
 # see output
 plot(prob)
 
# }

Run the code above in your browser using DataLab