library(raster)
# Using existing raster to create random binomial
r <- raster(system.file("external/rlogo.grd", package="raster"))
r <- random.raster(r, distribution="binomial")
# default; random, nrows=50, ncols=50, nlayers=1
rr <- random.raster(n.layer=5)
# specified; binomial, nrows=20, ncols=20, nlayers=5
rr <- random.raster(n.layer=5, n.col=20, n.row=20,
distribution="binomial")
# 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