Returns a function that performs random sampling on a spatial field.

sample_random(...)

Arguments

...

Additional arguments passed to terra::spatSample()

Value

A function that accepts x (SpatRaster) and size and returns an sf object

Examples

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

sam_field(rast_grid, 100, method = sample_random())
#> Simple feature collection with 100 features and 0 fields
#> Geometry type: POINT
#> Dimension:     XY
#> Bounding box:  xmin: 0.5 ymin: 0.5 xmax: 298.5 ymax: 97.5
#> CRS:           NA
#> First 10 features:
#>              geometry
#> 1  POINT (114.5 89.5)
#> 2   POINT (91.5 46.5)
#> 3  POINT (161.5 21.5)
#> 4   POINT (51.5 40.5)
#> 5  POINT (105.5 79.5)
#> 6    POINT (22.5 0.5)
#> 7  POINT (274.5 74.5)
#> 8   POINT (36.5 65.5)
#> 9   POINT (48.5 22.5)
#> 10  POINT (223.5 6.5)