
Last chance! 50% off unlimited learning
Sale ends in
## S3 method for class 'Raster':
sampleRandom(x, size, na.rm=TRUE, ext=NULL,
cells=FALSE, rowcol=FALSE, xy=FALSE, sp=FALSE, asRaster=FALSE, ...)
TRUE
(the default), NA
values are removed from random sampleTRUE
, sampled cell numbers are also returnedTRUE
, sampled row and column numbers are also returnedTRUE
, coordinates of sampled cells are also returnedTRUE
, a SpatialPointsDataFrame is returnedTRUE
, a Raster* object is returned with random cells with values, all other cells with NA
writeRaster
. Only relevant when asRaster=TRUE
cells=TRUE
or x
is a multi-layered object), or a SpatialPointsDataFrame (if sp=TRUE
)na.rm=TRUE
, the returned sample may be smaller than requestedsampleRegular, sampleStratified
r <- raster(system.file("external/test.grd", package="raster"))
sampleRandom(r, size=10)
s <- stack(r, r)
sampleRandom(s, size=5, cells=TRUE, sp=TRUE)
Run the code above in your browser using DataLab