Learn R Programming

sits (version 0.10.0)

sits_smooth.bayes: Post-process a classified data raster probs using bayesian smoothing

Description

Takes a set of raster bricks with probabilities, whose metadata is created by sits_cube, and apply a bayesian smoothing process. If covar is FALSE only main diagonal of covariance prior matrix will be computed.

Usage

# S3 method for bayes
sits_smooth(
  cube,
  type = "bayes",
  ...,
  window_size = 5,
  smoothness = 20,
  covar = FALSE,
  multicores = 1,
  memory = 1,
  output_dir = getwd(),
  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_probs (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.

multicores

Number of process to run the Bayesian smoothing in snow subprocess.

memory

Maximul overall memory (in GB) to run the Bayesian smoothing.

output_dir

Output directory where to out the file

version

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

Value

A tibble with metadata about the output raster objects.

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_bayes <- sits_smooth(sinop_probs, output_dir = tempdir()
    )
# }
# NOT RUN {
# }

Run the code above in your browser using DataLab