Learn R Programming

terra (version 0.4-3)

spatSample: Take a regular sample

Description

Take a regular sample of a SpatRaster. Either get cell values, or a new SpatRaster with the same extent, but fewer cells.

Usage

# S4 method for SpatRaster
spatSample(x, size, method="regular", as.raster=FALSE, ...)

Arguments

x

SpatRaster

size

numeric. The sample size

method

character. Should be "regular" (more to come)

as.raster

logical. If TRUE, a SpatRaster is returned

...

additional arguments. None implemented

Value

numeric or SpatRaster

Examples

Run this code
# NOT RUN {
f <- system.file("exdata/test.tif", package="terra")
r <- rast(f)
s <- spatSample(r, 100)
head(s)
ss <- spatSample(r, 100, as.raster=TRUE)
ss
# }

Run the code above in your browser using DataLab