raster (version 1.7-18)

sampleRandom: Random sample

Description

Take a random sample from a Raster* object.

Usage

sampleRandom(x, size, ...)

Arguments

x
a Raster object
size
positive integer giving the number of items to choose.
...
Additional arguments: na.rm Logical. If TRUE. NA values are removed from random sample extent Extent. To limit regular sampling to the area within the extent cells Logical. If

Value

  • A vector, matrix (if cells=TRUE; or for a multi-layered object), or a SpatialPointsDataFrame (if sp=TRUE)

Details

With na.rm=TRUE, the returned sample may be smaller than requested

See Also

sampleRegular

Examples

Run this code
r <- raster(system.file("external/test.grd", package="raster"))
 sampleRandom(r, size=10)
 s <- stack(r, r)
 sampleRandom(s, size=10, cells=TRUE, sp=TRUE)

Run the code above in your browser using DataLab