Learn R Programming

sits (version 0.13.0)

sits_classify: Classify time series or data cube using machine learning models

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:

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(), interp_fn = NULL, compose_fn = NULL, start_date = NULL, end_date = NULL, memsize = 8, multicores = 2, output_dir = tempdir(), version = "v1", verbose = FALSE )

Arguments

data

data cube

ml_model

R model trained by sits_train.

...

other parameters to be passed to specific functions

filter_fn

smoothing filter to be applied (if desired).

multicores

number of cores to be used for classification.

roi

a region of interest (see above)

impute_fn

impute function to replace NA

interp_fn

function to interpolate points from cube to match samples

compose_fn

function to compose points from cube to match samples

start_date

starting 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?

Value

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

Examples

Run this code
# NOT RUN {
# Example of classification of a time series
# Retrieve the samples for Mato Grosso
# select an extreme gradient boosting model
samples_2bands <- sits_select(samples_modis_4bands,
                            bands = c("NDVI", "EVI"))
xgb_model <- sits_train(samples_2bands,
    ml_method = sits_xgboost(verbose = FALSE)
)
# classify the point
point_2bands <- sits_select(samples_mt_6bands,
                            bands = c("NDVI", "EVI"))
point_class <- sits_classify(point_2bands, xgb_model)
plot(point_class)

# create a data cube based on files
data_dir <- system.file("extdata/raster/mod13q1", package = "sits")
cube <- sits_cube(
    source = "LOCAL",
    name = "sinop-2014",
    satellite = "TERRA",
    sensor = "MODIS",
    data_dir = data_dir,
    delim = "_",
    parse_info = c("X1", "X2", "tile", "band", "date")
)

# classify the raster image
probs_cube <- sits_classify(cube,
    ml_model = xgb_model,
    output_dir = tempdir(),
    memsize = 4, multicores = 2
)

# label the classified image
label_cube <- sits_label_classification(probs_cube, output_dir = tempdir())
plot(label_cube)
# }
# NOT RUN {
# }

Run the code above in your browser using DataLab