bayes_variance {bayesEO} | R Documentation |
Calculate the variance of a probability cube
Description
Takes a probability cube and estimate the local variance of the logit of the probability, to support the choice of parameters for Bayesian smoothing.
Usage
bayes_variance(x, window_size = 9, neigh_fraction = 0.5)
Arguments
x |
SpatRaster object containing probabilities. |
window_size |
Size of the neighborhood. |
neigh_fraction |
Fraction of neighbors with highest probability to be used in Bayesian inference. |
Value
A variance SpatRaster object.
Author(s)
Gilberto Camara, gilberto.camara@inpe.br
Rolf Simoes, rolf.simoes@inpe.br
Examples
if (bayes_run_examples()) {
# select a file with probability values
data_dir <- system.file("/extdata/probs/", package = "bayesEO")
file <- list.files(data_dir)
# create a SpatRaster object from the file
x <- terra::rast(paste0(data_dir, "/", file))
# provide the labels
labels <- c("Water", "ClearCut_Burn", "ClearCut_Soil",
"ClearCut_Veg", "Forest", "Wetland")
# name the layers in the SpatRaster with the labels
names(x) <- labels
# calculate the variance
v <- bayes_variance(x)
# plot the variance
bayes_plot_var(v, quantile = 0.75)
}
[Package bayesEO version 0.2.1 Index]