sits_label_classification: Build a labelled image from a probability cube

View source: R/sits_label_classification.R

sits_label_classificationR Documentation

Build a labelled image from a probability cube

Description

Takes a set of classified raster layers with probabilities, and label them based on the maximum probability for each pixel.

Usage

sits_label_classification(
  cube,
  clean = TRUE,
  window_size = 3L,
  memsize = 4,
  multicores = 2,
  output_dir,
  version = "v1",
  progress = TRUE
)

## S3 method for class 'probs_cube'
sits_label_classification(
  cube,
  ...,
  clean = TRUE,
  window_size = 3L,
  memsize = 4L,
  multicores = 2L,
  output_dir,
  version = "v1",
  progress = TRUE
)

## S3 method for class 'probs_vector_cube'
sits_label_classification(
  cube,
  ...,
  output_dir,
  version = "v1",
  progress = TRUE
)

## S3 method for class 'raster_cube'
sits_label_classification(cube, ...)

## S3 method for class 'derived_cube'
sits_label_classification(cube, ...)

## S3 method for class 'tbl_df'
sits_label_classification(cube, ...)

## Default S3 method:
sits_label_classification(cube, ...)

Arguments

cube

Classified image data cube.

clean

A logical value to apply a modal function to clean up possible noisy pixels keeping the most frequently values within the neighborhood. Default is TRUE.

window_size

An odd integer representing the size of the sliding window of the modal function (min = 1, max = 15).

memsize

maximum overall memory (in GB) to label the classification.

multicores

Number of workers to label the classification in parallel.

output_dir

Output directory for classified files.

version

Version of resulting image (in the case of multiple runs).

progress

Show progress bar?

...

Other parameters for specific functions.

Value

A data cube with an image with the classified map.

Note

Please refer to the sits documentation available in <https://e-sensing.github.io/sitsbook/> for detailed examples.

Author(s)

Rolf Simoes, rolf.simoes@inpe.br

Felipe Souza, felipe.souza@inpe.br

Examples

if (sits_run_examples()) {
    # create a random forest model
    rfor_model <- sits_train(samples_modis_ndvi, sits_rfor())
    # 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
    )
    # classify a data cube
    probs_cube <- sits_classify(
        data = cube, ml_model = rfor_model, output_dir = tempdir()
    )
    # plot the probability cube
    plot(probs_cube)
    # smooth the probability cube using Bayesian statistics
    bayes_cube <- sits_smooth(probs_cube, output_dir = tempdir())
    # plot the smoothed cube
    plot(bayes_cube)
    # label the probability cube
    label_cube <- sits_label_classification(
        bayes_cube,
        output_dir = tempdir()
    )
    # plot the labelled cube
    plot(label_cube)
}

sits documentation built on Nov. 2, 2023, 5:59 p.m.