Description Usage Arguments Value See Also Examples
Given a multilayer raster preds
where each layer is a single bootstrap or ensemble prediction, calculate mean, median and and quantile (specified by quantiles
) rasters.
1 2 | combinePreds(preds, quantiles = c(0.025, 0.975),
parallel = FALSE, ncore = NULL)
|
preds |
A |
quantiles |
A vector of length two giving the quantiles of the prediciton distribution to return. |
parallel |
Whether to run the function in parallel. The user can specify the number of cores to run on via the |
ncore |
If |
A RasterBrick
or RasterStack
object (whichever preds
was) giving the mean, median and as many quantiles as were requested (default 2) of the predictive distribution at each pixel.
RasterBrick
, RasterStack
, quantile
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 | # load a test raster
r <- raster(system.file("external/test.grd", package="raster"))
# generate multiple layers with random perturbations
preds <- lapply(1:10, function(i, raster) {
raster[] <- raster[] + rnorm(ncell(raster), 0, 10 * sqrt(raster[] + 1))
raster
}, r)
# turn them into a brick
preds <- brick(preds)
# combine them, returning the mean and the 10% and 90% quantiles
preds_comb <- combinePreds(preds, quantiles = c(0.1, 0.9))
# calculate the inter-quantile range
preds_comb[[5]] <- preds_comb[[4]] - preds_comb[[3]]
names(preds_comb)[5] <- 'iq_range'
# plot them
plot(preds_comb)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.