Learn R Programming

sits (version 1.4.1)

sits_classify: Classify time series or data cubes

Description

This function classifies a set of time series or data cube given a trained model prediction model created by sits_train.

SITS supports the following models:

  • support vector machines: see sits_svm

  • random forests: see sits_rfor

  • extreme gradient boosting: see sits_xgboost

  • multi-layer perceptrons: see sits_mlp

  • 1D CNN: see sits_tempcnn

  • deep residual networks:see sits_resnet

  • self-attention encoders:see sits_lighttae

Usage

sits_classify(
  data,
  ml_model,
  ...,
  filter_fn = NULL,
  multicores = 2,
  progress = TRUE
)

# S3 method for sits sits_classify( data, ml_model, ..., filter_fn = NULL, multicores = 2, progress = TRUE )

# S3 method for raster_cube sits_classify( data, ml_model, ..., roi = NULL, filter_fn = NULL, start_date = NULL, end_date = NULL, memsize = 8, multicores = 2, output_dir, version = "v1", verbose = FALSE, progress = TRUE )

Value

Predicted data (classified time series) or a data cube with probabilities for each class.

Arguments

data

Data cube.

ml_model

R model trained by sits_train.

...

Other parameters for specific functions.

filter_fn

Smoothing filter to be applied (if desired).

multicores

Number of cores to be used for classification.

progress

Show progress bar?

roi

Region of interest (see below)

start_date

Start date for the classification.

end_date

End date for the classification.

memsize

Memory available for classification (in GB).

output_dir

Directory for output file.

version

Version of the output (for multiple classifications).

verbose

Print information about processing time?

Author

Rolf Simoes, rolf.simoes@inpe.br

Gilberto Camara, gilberto.camara@inpe.br

Examples

Run this code
if (sits_run_examples()) {
    # Example of classification of a time series
    # Retrieve the samples for Mato Grosso
    # train a random forest model
    rf_model <- sits_train(samples_modis_ndvi, ml_method = sits_rfor)

    # classify the point
    point_ndvi <- sits_select(point_mt_6bands, bands = c("NDVI"))
    point_class <- sits_classify(
        data = point_ndvi, ml_model = rf_model
    )
    plot(point_class)

    # Example of classification of a data cube
    # create a data cube from local files
    data_dir <- system.file("extdata/raster/mod13q1", package = "sits")
    cube <- sits_cube(
        source = "BDC",
        collection = "MOD13Q1-6",
        data_dir = data_dir
    )
    # classify a data cube
    probs_cube <- sits_classify(
        data = cube, ml_model = rf_model, output_dir = tempdir()
    )
    # label the probability cube
    label_cube <- sits_label_classification(
        probs_cube, output_dir = tempdir()
    )
    # plot the classified image
    plot(label_cube)
}

Run the code above in your browser using DataLab