Learn R Programming

sits (version 1.1.0)

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, ...)

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

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

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.

roi

Region of interest (see below)

impute_fn

Impute function to replace NA.

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?

progress

Show progress bar?

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
    # select the NDVI band
    samples_ndvi <- sits_select(samples_modis_4bands, bands = c("NDVI"))
    # train a random forest model
    rf_model <- sits_train(samples_ndvi, ml_method = sits_rfor)

    # classify the point
    point_ndvi <- sits_select(point_mt_6bands, bands = c("NDVI"))
    point_class <- sits_classify(point_ndvi, 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,
        delim = "_",
        parse_info = c("X1", "X2", "tile", "band", "date")
    )
    # classify a data cube
    probs_cube <- sits_classify(data = cube, ml_model = rf_model)
    # label the probability cube
    label_cube <- sits_label_classification(probs_cube)
    # plot the classified image
    plot(label_cube)
}

Run the code above in your browser using DataLab