
Last chance! 50% off unlimited learning
Sale ends in
Create a random raster or raster stack using specified distribution
random.raster(
r = NULL,
n.row = 50,
n.col = 50,
n.layers = 1,
x = seq(1, 10),
min = 0,
max = 1,
mean = 0,
sd = 1,
p = 0.5,
s = 1.5,
distribution = c("random", "normal", "seq", "binominal", "gaussian")
)
Optional existing raster defining nrow/ncol
Number of rows
Number of columns
Number of layers in resulting raster stack
A vector of values to sample if distribution is "sample"
Minimum value of raster
Maximum value of raster
Mean of centered distribution
Standard deviation of centered distribution
p-value for binominal distribution
sigma value for Gaussian distribution
Available distributions, c("random", "normal", "seq", "binominal", "gaussian", "sample")
RasterLayer or RasterStack object with random rasters
Options for distributions are for random, normal, seq, binominal, gaussian and sample raster(s)
# NOT RUN {
library(raster)
# Using existing raster to create random binominal
r <- raster(system.file("external/rlogo.grd", package="raster"))
r <- random.raster(r, distribution="binominal")
# default; random, nrows=50, ncols=50, nlayers=1
rr <- random.raster(n.layer=5)
# specified; binominal, nrows=20, ncols=20, nlayers=5
rr <- random.raster(n.layer=5, n.col=20, n.row=20,
distribution="binominal")
# specified; gaussian, nrows=50, ncols=50, nlayers=1
rr <- random.raster(n.col=50, n.row=50, s=8,
distribution="gaussian")
# specified; sample, nrows=50, ncols=50, nlayers=1
rr <- random.raster(n.layer=1, x=c(2,6,10,15), distribution="sample" )
freq(rr)
# }
Run the code above in your browser using DataLab