process_surface | R Documentation |
This function reduces the resolution of a raster
by multiple aggregation methods and then quantifies the relative error induced by each method from the differences between the original values and the aggregated values. To implement the function, a raster
(x
) must be supplied as well as an aggregation factor (fact
) and a named list of functions (stat
) used to aggregate the raster
. The raster
is aggregated using each method (function) and mapped back onto the original resolution for calculation of the differences between the original raster
and the aggregated raster
(s). The function returns a visual statistical summary of the differences (if plot = TRUE
) and a named list comprising the aggregated raster
(s) and the re-sampled version(s) of those mapped back onto the original resolution.
process_surface(
x,
fact = 2L,
stat = list(mean = mean),
...,
plot = TRUE,
cl = NULL,
varlist = NULL,
verbose = TRUE
)
x |
A |
fact |
A positive integer that defines by how much |
stat |
A named list of functions used to aggregate |
... |
Additional arguments passed to |
plot |
A logical input that defines whether or not to plot a summary of the differences between the original |
cl , varlist |
(optional) Parallelisation options. |
verbose |
A logical input that defines whether or not to print messages to the console to relay function progress. |
This function was motivated by the particle filtering algorithms in flapper
(e.g., pf
). For these algorithms, it is computationally beneficial to reduce raster
resolution, where possible, by aggregation. To facilitate this process, this function quantifies the relative error induced by different aggregation functions. If appropriate, the particle filtering algorithm(s) can then be implemented using the aggregated raster
that minimises the error, with the magnitude of that error propagated via the depth_error
parameter.
The function returns a plot of the differences between the original and aggregated raster
(s), if plot = TRUE
, and a named list of (a) the aggregated raster
(s) (‘agg_by_stat’), (b) the aggregated, resampled raster
(s) (‘agg_by_stat_rs’) and (c) the summary statistics plotted.
Edward Lavender
aggregate
, resample
# Define the raster for which to implement the function
x <- dat_gebco
blank <- raster::raster(raster::extent(x), crs = raster::crs(x), resolution = 250)
x <- raster::resample(x, blank, method = "bilinear")
# Implement function using a list of statistics
out <- process_surface(x, fact = 2, stat = list(min = min, mean = mean, median = median, max = max))
summary(out)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.