sits_smooth: Smooth probability cubes with spatial predictors

View source: R/sits_smooth.R

sits_smoothR Documentation

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 = 7L,
  neigh_fraction = 0.5,
  smoothness = 10L,
  memsize = 4L,
  multicores = 2L,
  output_dir,
  version = "v1"
)

## S3 method for class 'probs_cube'
sits_smooth(
  cube,
  window_size = 7L,
  neigh_fraction = 0.5,
  smoothness = 10L,
  memsize = 4L,
  multicores = 2L,
  output_dir,
  version = "v1"
)

## S3 method for class 'raster_cube'
sits_smooth(
  cube,
  window_size = 7L,
  neigh_fraction = 0.5,
  smoothness = 10L,
  memsize = 4L,
  multicores = 2L,
  output_dir,
  version = "v1"
)

## S3 method for class 'derived_cube'
sits_smooth(
  cube,
  window_size = 7L,
  neigh_fraction = 0.5,
  smoothness = 10L,
  memsize = 4L,
  multicores = 2L,
  output_dir,
  version = "v1"
)

## S3 method for class 'tbl_df'
sits_smooth(
  cube,
  window_size = 7L,
  neigh_fraction = 0.5,
  smoothness = 10L,
  memsize = 4L,
  multicores = 2L,
  output_dir,
  version = "v1"
)

## Default S3 method:
sits_smooth(
  cube,
  window_size = 7L,
  neigh_fraction = 0.5,
  smoothness = 10L,
  memsize = 4L,
  multicores = 2L,
  output_dir,
  version = "v1"
)

Arguments

cube

Probability data cube.

window_size

Size of the neighborhood (integer, min = 3, max = 21)

neigh_fraction

Fraction of neighbors with high probabilities to be used in Bayesian inference. (numeric, min = 0.1, max = 1.0)

smoothness

Estimated variance of logit of class probabilities (Bayesian smoothing parameter) (integer vector or scalar, min = 1, max = 200).

memsize

Memory available for classification in GB (integer, min = 1, max = 16384).

multicores

Number of cores to be used for classification (integer, min = 1, max = 2048).

output_dir

Valid directory for output file. (character vector of length 1).

version

Version of the output (character vector of length 1).

Value

A data cube.

Author(s)

Gilberto Camara, gilberto.camara@inpe.br

Rolf Simoes, rolf.simoes@inpe.br

Examples

if (sits_run_examples()) {
    # create am xgboost model
    xgb_model <- sits_train(samples_modis_ndvi, sits_xgboost())
    # 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 = xgb_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.