This function utilizes anticlust::balanced_clustering()
to split the input into equal size subgroups then transform the data
to be compatible with the output of par_pad_grid, for which
a set of padded grids of the extent of input point subsets
(as recorded in the field named "CGRIDID")
is generated out of input points.
Value
A list of two,
original: exhaustive and non-overlapping grid polygons in the class of inputpadded: a square buffer of each polygon inoriginal. Used for computation.
Examples
lastpar <- par(mfrow = c(1, 1))
library(terra)
library(sf)
options(sf_use_s2 = FALSE)
ncpath <- system.file("gpkg/nc.gpkg", package = "sf")
nc <- terra::vect(ncpath)
nc_rp <- terra::spatSample(nc, 1000)
nc_gr <- par_pad_balanced(nc_rp, 10L, 1000)
nc_gr
#> $original
#> class : SpatVector
#> geometry : points
#> dimensions : 1000, 15 (geometries, attributes)
#> extent : -84.31143, -75.84704, 33.91155, 36.557 (xmin, xmax, ymin, ymax)
#> coord. ref. : lon/lat NAD27 (EPSG:4267)
#> names : AREA PERIMETER CNTY_ CNTY_ID NAME FIPS FIPSNO CRESS_ID
#> type : <num> <num> <num> <num> <chr> <chr> <num> <int>
#> values : 0.212 2.024 2241 2241 Brunswick 37019 3.702e+04 10
#> 0.12 1.686 2088 2088 Cherokee 37039 3.704e+04 20
#> 0.121 1.855 2107 2107 Richmond 37153 3.715e+04 77
#> BIR74 SID74 (and 5 more)
#> <num> <num>
#> 2181 5
#> 1027 2
#> 2756 4
#>
#> $padded
#> class : SpatVector
#> geometry : polygons
#> dimensions : 10, 1 (geometries, attributes)
#> extent : -1084.311, 924.153, -966.0884, 1036.557 (xmin, xmax, ymin, ymax)
#> coord. ref. :
#> names : CGRIDID
#> type : <num>
#> values : 1
#> 2
#> 3
#>
par(lastpar)