Learn R Programming

sits (version 0.10.0)

sits_label_majority: Post-process a classified data raster with a majority filter

Description

Takes a set of classified raster layers with labels, and executes a majority filter for post-processing.

Usage

sits_label_majority(cube, window_size = 3, output_dir = "./", version = "v1")

Arguments

cube

Classified image data cube.

window_size

Size of the window to apply majority filter

output_dir

Output directory where to out the file

version

Version of resulting image (in the case of multiple tests)

Value

A data cube with metadata information on post-processed data

Examples

Run this code
# NOT RUN {
# Retrieve the samples for Mato Grosso
# select band "ndvi"

samples_ndvi <- sits_select(samples_mt_4bands, bands = "NDVI")

# select a random forest model
rfor_model <- sits_train(samples_ndvi, sits_rfor(num_trees = 500))

# Classify a raster file with 23 instances for one year
files <- c(system.file("extdata/raster/mod13q1/sinop-crop-ndvi.tif",
    package = "sits"
))

# create a data cube based on the information about the files
sinop <- sits_cube(
    type = "BRICK", satellite = "TERRA",
    sensor = "MODIS", name = "Sinop-crop",
    timeline = timeline_modis_392,
    output_dir = tempdir(),
    bands = c("NDVI"), files = files
)

# classify the raster image
sinop_probs <- sits_classify(sinop,
    ml_model = rfor_model,
    output_dir = tempdir(),
    memsize = 4, multicores = 2
)

# label the classification and smooth the result with a bayesian filter
sinop_label <- sits_label_classification(sinop_probs, output_dir = tempdir())

# smooth the result with a majority filter
sinop_label_maj <- sits_label_majority(sinop_label, output_dir = tempdir())

# }

Run the code above in your browser using DataLab