Learn R Programming

sits (version 1.1.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 smoothing function. There are three options, defined by the "type" parameter:

  • "bayes": Use a bayesian smoother

  • "bilateral: Use a bilateral smoother

Usage

sits_smooth(cube, type = "bayes", ...)

# S3 method for bayes sits_smooth( cube, type = "bayes", ..., window_size = 5, smoothness = 20, covar = FALSE, multicores = 2, memsize = 4, output_dir = ".", version = "v1" )

# S3 method for bilateral sits_smooth( cube, type = "bilateral", ..., window_size = 5, sigma = 8, tau = 0.1, multicores = 2, memsize = 4, output_dir = ".", version = "v1" )

Value

A tibble with metadata about the output raster objects.

Arguments

cube

Probability data cube

type

Type of smoothing

...

Parameters for specific functions

window_size

Size of the neighbourhood.

smoothness

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

covar

a logical argument indicating if a covariance matrix must be computed as the prior covariance for bayesian smoothing.

multicores

Number of cores to run the smoothing function

memsize

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

output_dir

Output directory for image files

version

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

sigma

Standard deviation of the spatial Gaussian kernel (for bilateral smoothing)

tau

Standard deviation of the class probs value (for bilateral smoothing)

Author

Gilberto Camara, gilberto.camara@inpe.br

Rolf Simoes, rolf.simoes@inpe.br

References

K. Schindler, "An Overview and Comparison of Smooth Labeling Methods for Land-Cover Classification", IEEE Transactions on Geoscience and Remote Sensing, 50 (11), 4534-4545, 2012 (for gaussian and bilateral smoothing)

Examples

Run this code
if (sits_run_examples()) {
    # select a set of samples
    samples_ndvi <- sits_select(samples_modis_4bands, bands = c("NDVI"))
    # create a ResNet model
    torch_model <- sits_train(samples_ndvi, sits_resnet())
    # plot the model
    plot(torch_model)
    # 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,
        delim = "_",
        parse_info = c("X1", "X2", "tile", "band", "date")
    )
    # classify a data cube
    probs_cube <- sits_classify(data = cube, ml_model = torch_model)
    # plot the probability cube
    plot(probs_cube)
    # smooth the probability cube using Bayesian statistics
    bayes_cube <- sits_smooth(probs_cube)
    # plot the smoothed cube
    plot(bayes_cube)
    # label the probability cube
    label_cube <- sits_label_classification(bayes_cube)
    # plot the labelled cube
    plot(label_cube)
}

Run the code above in your browser using DataLab