Create a sample of a spatial field.

sam_field(x, size, type = "", value, nclusters, ...)

Arguments

x

A raster object.

size

Number of samples to create.

type

Expected spatial distribution of the samples. Possible values are: "jittered", "random", "clustered".

value

Amount of jitter to apply to the samples (in map units; only used when type = "jittered") or radius of the buffer around each cluster (only used when type = "clustered").

nclusters

Number of clusters to simulate. Only used when type = "clustered".

...

Additional arguments passed to terra::spatSample().

Examples

rast_grid = terra::rast(ncols = 300, nrows = 100, xmin = 0, xmax = 300, ymin = 0, ymax = 100)
sam_field(rast_grid, 100, "jittered", 5)
#> Simple feature collection with 108 features and 0 fields
#> Geometry type: POINT
#> Dimension:     XY
#> Bounding box:  xmin: 4.4779 ymin: 3.735812 xmax: 294.5015 ymax: 96.15376
#> CRS:           NA
#> First 10 features:
#>                     geometry
#> 1   POINT (5.53674 3.735812)
#> 2  POINT (26.16662 5.221823)
#> 3   POINT (44.35406 6.63006)
#> 4   POINT (60.66815 9.56979)
#> 5   POINT (79.15347 8.74139)
#> 6  POINT (95.84905 9.437398)
#> 7  POINT (112.3639 12.04038)
#> 8  POINT (121.8196 12.11388)
#> 9  POINT (144.9495 5.885855)
#> 10 POINT (160.6316 6.186852)