R: Post-process a classified data raster probs using smoothing

sits_smooth {sits} | R Documentation

## Post-process a classified data raster probs using smoothing

### 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

- "gaussian": Use a gaussian smoother

- "bilateral: Use a bilateral smoother

### Usage

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

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

    ## S3 method for class 'gaussian'
    sits_smooth(
      cube,
      type = "gaussian",
      ...,
      window_size = 5,
      sigma = 1,
      multicores = 2,
      memsize = 4,
      output_dir = tempdir(),
      version = "v1"
    )

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

### 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 gaussian and bilateral smoothing)
`tau` | Standard deviation of the class probs value (for bilateral smoothing)

### Value

A tibble with metadata about the output raster objects.

### Author(s)

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

    ## Not run:
    # Retrieve the samples for Mato Grosso
    # select band "ndvi"

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

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

    # create a data cube based on the information about the 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 = rfor_model,
        output_dir = tempdir(),
        memsize = 4, multicores = 2
    )

    # smooth the result with a bayesian filter
    bayes_cube <- sits_smooth(probs_cube,
         type = "bayes", output_dir = tempdir()
    )

    # smooth the result with a gaussian filter
    gauss_cube <- sits_smooth(probs_cube,
        type = "gaussian", output_dir = tempdir()
    )

    # smooth the result with a bilateral filter
    bil_cube <- sits_smooth(probs_cube,
        type = "bilateral", output_dir = tempdir()
    )

    ## End(Not run)

[Package sits version 0.14.1 Index]