randomPts: Generate random points within a raster object.

View source: R/raster.R

randomPtsR Documentation

Generate random points within a raster object.

Description

Providing a polygon to limit the search area can speed up the search if the polygon is small relative to the area of a layer.

Usage

randomPts(x, n = 100, m = 2, na.rm = FALSE, pts = NULL, polygon = NULL)

Arguments

x

Raster* layer, brick or stack

n

numeric, the number of points to return

m

multiplier to use when seeking to avoid missing values. Ignored if polygon is provided.

na.rm

logical, if TRUE then avoid cells with missing values.

pts

a table of points to avoid. If na.rm is TRUE that is handled first, then point avoidance is handled. Ignored if NULL.

polygon

polygon (sfc or SpatialPolygon) that describes the region to select points from. Ignored if NULL.

Value

a table of locations with values. Note that it is possible to filter the available pool of candidate cells to something less than the requested sample, n. In such cases some samples may be replicates.


BigelowLab/rasf documentation built on July 18, 2022, 10:19 p.m.