
Last chance! 50% off unlimited learning
Sale ends in
v
from 'x', 'y', 'col', 'row', or 'cell'.
When using a function, cell values are initialized without reference to pre-existing values. E.g., initialize with a random number (fun=runif
).
Either supply an argument to fun
, or to v
, but not both.init(raster, fun, v, filename="", ...)
writeRaster
r <- raster(ncols=36, nrows=18)
r <- init(r, fun=runif)
# there are different ways to set all values to 1
set1f <- function(x){rep(1, x)}
r <- init(r, fun=set1f, filename='test.grd', overwrite=TRUE)
# easier to do "manually"
r <- setValues(r, rep(1, ncell(r)))
# or
r[] <- rep(1, ncell(r))
r[] <- 1
Run the code above in your browser using DataLab