sample_clustered.RdReturns a function that performs clustered sampling on a spatial field. Cluster centers are randomly distributed, then samples are drawn within a buffer radius around each cluster.
sample_clustered(nclusters, radius, ...)Number of clusters
Cluster radius (in map units)
Additional arguments passed to terra::spatSample()
A function that accepts x (SpatRaster) and size and returns an sf object
rast_grid = terra::rast(
ncols = 300, nrows = 100,
xmin = 0, xmax = 300,
ymin = 0, ymax = 100
)
sam_field(rast_grid, 200, method = sample_clustered(nclusters = 5, radius = 10))
#> Simple feature collection with 200 features and 1 field
#> Geometry type: POINT
#> Dimension: XY
#> Bounding box: xmin: 12.5 ymin: 0.5 xmax: 276.5 ymax: 97.5
#> CRS: NA
#> First 10 features:
#> lyr.1 geometry
#> 1 1 POINT (27.5 90.5)
#> 2 1 POINT (20.5 85.5)
#> 3 1 POINT (20.5 92.5)
#> 4 1 POINT (22.5 86.5)
#> 5 1 POINT (22.5 91.5)
#> 6 1 POINT (20.5 93.5)
#> 7 1 POINT (27.5 86.5)
#> 8 1 POINT (26.5 95.5)
#> 9 1 POINT (13.5 95.5)
#> 10 1 POINT (17.5 80.5)