RStoolbox (version 0.2.6)

predict.superClass: 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

# S3 method for 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

Run this code
# NOT RUN {
## 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)
# }

Run the code above in your browser using DataCamp Workspace