Predict a raster map based on a superClass model fit.

Description

useful to separate model fitting from spatial prediction, which can take some time.

Usage

1
2
3
## S3 method for class 'superClass'
predict(object, img, predType = "raw", filename = NULL,
  datatype = "INT2U", ...)

Arguments

object

superClass object

img

Raster object. Layernames must correspond to layernames used to train the superClass model, i.e. layernames in the original raster image.

predType

Character. Type of the final output raster. Either "raw" for class predictions or "prob" for class probabilities. Class probabilities are not available for all classification models (predict.train).

filename

Character or NULL. Filename for output raster file.

datatype

Datatype of output raster file.

...

Further arguments passed to writeRaster.

Examples

1
2
3
4
5
6
7
8
9
## Load training data
data(rlogo)
train <- readRDS(system.file("external/trainingPoints.rds", package="RStoolbox"))

## Fit classifier 
SC 	  <- superClass(rlogo, trainData = train, responseCol = "class", 
              model = "rf", tuneLength = 1, predict = FALSE)

map <- predict(SC, rlogo)

Want to suggest features or report bugs for rdrr.io? Use the GitHub issue tracker.