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 205 features and 1 field
#> Geometry type: POINT
#> Dimension: XY
#> Bounding box: xmin: 53.5 ymin: 2.5 xmax: 240.5 ymax: 99.5
#> CRS: NA
#> First 10 features:
#> lyr.1 geometry
#> 1 1 POINT (230.5 86.5)
#> 2 1 POINT (172.5 78.5)
#> 3 1 POINT (134.5 11.5)
#> 4 1 POINT (62.5 90.5)
#> 5 1 POINT (99.5 61.5)
#> 6 1 POINT (225.5 94.5)
#> 7 1 POINT (237.5 87.5)
#> 8 1 POINT (226.5 95.5)
#> 9 1 POINT (225.5 80.5)
#> 10 1 POINT (235.5 87.5)