Create a sample of a spatial field.

sam_field(x, size, method = sample_random())

Arguments

x

A raster object (SpatRaster).

size

Number of samples to create.

method

Sampling method (function created by sample_random(), sample_jittered(), or sample_clustered()).

Value

An sf object with sampled points

Examples

rast_grid = terra::rast(
  ncols = 300, nrows = 100,
  xmin = 0, xmax = 300,
  ymin = 0, ymax = 100
)

sam_field(
  rast_grid,
  100,
  method = sample_jittered(amount = 5)
)
#> Simple feature collection with 100 features and 0 fields
#> Geometry type: POINT
#> Dimension:     XY
#> Bounding box:  xmin: 3.53674 ymin: 7.735812 xmax: 298.131 ymax: 92.44239
#> CRS:           NA
#> First 10 features:
#>                     geometry
#> 1   POINT (3.53674 17.12569)
#> 2  POINT (19.16662 13.00921)
#> 3  POINT (33.35406 11.43429)
#> 4  POINT (44.66815 8.677757)
#> 5  POINT (58.15347 17.24811)
#> 6   POINT (70.84905 9.97177)
#> 7  POINT (82.36387 17.16723)
#> 8  POINT (86.81957 14.67611)
#> 9  POINT (105.9495 7.735812)
#> 10 POINT (116.6316 9.221823)