| sits_classify {sits} | R Documentation |
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
linear discriminant analysis: see sits_lda
quadratic discriminant analysis: see sits_qda
multinomial logit: see sits_mlr
extreme gradient boosting: see sits_xgboost
multi-layer perceptrons: see sits_mlp
mixed 1D CNN and MLP networks: see sits_TempCNN
deep residual netwroks:see sits_ResNet
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(), interp_fn = NULL, compose_fn = NULL, start_date = NULL, end_date = NULL, memsize = 8, multicores = 2, output_dir = tempdir(), version = "v1", verbose = FALSE, progress = FALSE )
data |
data cube |
ml_model |
R model trained by |
... |
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? |
progress |
a logical value indicating if a progress bar should be shown |
Predicted data (classified time series) or a data cube with probabilities for each class.
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 ("lat_min", "lat_max", "lon_min", "lon_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 "interp_fn" function is used when the training samples which were used to generate the classification model have a larger number of time instances than the data cube. In this case, pixel time series of the data cube will have to be interpolated to fit that of the samples.
The "compose_fn" function is used when the training samples which were used to generate the classification model have a small number of time instances than the data cube. In this case, pixel time series of the data cube will have to be composed and/or merged to fit that of the samples.
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.
Rolf Simoes, rolf.simoes@inpe.br
Gilberto Camara, gilberto.camara@inpe.br
# 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",
origin = "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)