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: 1.5 ymin: 0.5 xmax: 299.5 ymax: 99.5
#> CRS:           NA
#> First 10 features:
#>              geometry
#> 1   POINT (80.5 21.5)
#> 2  POINT (119.5 48.5)
#> 3  POINT (118.5 71.5)
#> 4  POINT (258.5 63.5)
#> 5  POINT (265.5 94.5)
#> 6  POINT (189.5 34.5)
#> 7  POINT (225.5 38.5)
#> 8  POINT (298.5 22.5)
#> 9   POINT (104.5 4.5)
#> 10 POINT (225.5 24.5)