View source: R/spatial_tools.R
sim_surface | R Documentation |
This function is designed to populate a raster with simulated values. To implement the function, a (blank) raster should be supplied. A user-defined function, or list of functions, is evaluated across this raster, or across sub-regions of this raster, to generate a new raster with simulated values.
sim_surface(
blank,
n = 1L,
sim_values,
mask = NULL,
mask_inside = FALSE,
plot = 1:2L
)
blank |
A |
n |
An integer that defines the number of (approximately equal area) pieces into which to split |
sim_values |
A function or, if |
mask , mask_inside |
Arguments required to implement a spatial mask via |
plot |
An integer that defines whether or not to plot a histogram of simulated values ( |
The function returns a raster
, with the same properties as blank
, with values generated from the sim_values
function(s).
Edward Lavender
#### Example (1): Simulate values across the whole raster
sim_surface(dat_gebco,
sim_values = function(n) stats::runif(n = n, 0, 1)
)
sim_surface(dat_gebco,
sim_values = function(n) stats::rnorm(n = n, 0, 1)
)
#### Example (2): Simulate values differently across different areas
# .. by defining the number of areas into which to split the raster
# .. and a list of function(s)
sim_surface(dat_gebco,
n = 2, sim_values = list(
function(n) stats::runif(n = n, 0, 1),
function(n) stats::runif(n = n, 10, 11)
)
)
#### Example (3): Include a spatial mask
sim_surface(dat_gebco,
n = 2, sim_values = list(
function(n) stats::runif(n = n, 9, 10),
function(n) stats::runif(n = n, 10, 11)
),
mask = dat_coast, mask_inside = TRUE
)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.