sits_classify {sits}R Documentation

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:

Usage

sits_classify(data, ml_model, ...)

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

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

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 below)

impute_fn

impute function to replace NA

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?

progress

a logical value indicating if a progress bar should be shown

Value

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

Note

The "roi" parameter defines a region of interest. It can be an sf_object, a shapefile, or a bounding box vector with named XY values ("xmin", "xmax", "ymin", "ymax") or named lat/long values ("lon_min", "lat_min", "lon_max", "lat_max")

The "filter_fn" parameter specifies a smoothing filter to be applied to time series for reducing noise. Currently, options include Savtizky-Golay (see sits_sgolay) and Whittaker (see sits_whittaker).

The "impute_fn" function is used to remove invalid or cloudy pixels from time series. The default is a linear interpolator, available in sits_impute_linear. Users can add their custom functions.

The "memsize" and "multicores" parameters are used for multiprocessing. The "multicores" parameter defines the number of cores used for processing. The "memsize" parameter controls the amount of memory available for classification. We recommend using a 4:1 relation between "memsize" and "multicores".

Author(s)

Rolf Simoes, rolf.simoes@inpe.br

Gilberto Camara, gilberto.camara@inpe.br

Examples


# 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("EVI", "NDVI"))
xgb_model <- sits_train(samples_2bands,
    ml_method = sits_xgboost(verbose = FALSE)
)
# classify the point
point_2bands <- sits_select(point_mt_6bands,
                            bands = c("EVI", "NDVI"))
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 = "BDC",
    collection = "MOD13Q1-6",
    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)



[Package sits version 0.16.2 Index]