Learn R Programming

sits (version 1.4.0)

sits_smooth: Smooth probability cubes with spatial predictors

Description

Takes a set of classified raster layers with probabilities, whose metadata is]created by sits_cube, and applies a Bayesian smoothing function.

Usage

sits_smooth(
  cube,
  window_size = 7,
  neigh_fraction = 0.5,
  smoothness = 10,
  memsize = 4,
  multicores = 2,
  output_dir,
  version = "v1"
)

Value

A data cube.

Arguments

cube

Probability data cube.

window_size

Size of the neighborhood.

neigh_fraction

Fraction of neighbors with high probabilities to be used in Bayesian inference.

smoothness

Estimated variance of logit of class probabilities (Bayesian smoothing parameter). It can be either a vector or a scalar.

memsize

Maximum overall memory (in GB) to run the smoothing.

multicores

Number of cores to run the smoothing function

output_dir

Output directory for image files

version

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

Author

Gilberto Camara, gilberto.camara@inpe.br

Rolf Simoes, rolf.simoes@inpe.br

Examples

Run this code
if (sits_run_examples()) {
    # create a ResNet model
    torch_model <- sits_train(samples_modis_ndvi, sits_resnet(epochs = 20))
    # 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 = torch_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)
}

Run the code above in your browser using DataLab