Skip to contents

This function is an extension of par_group_balanced to be compatible with par_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 along with the output of par_group_balanced.

Usage

par_group_grid(points_in = NULL, ngroups, padding)

Arguments

points_in

sf or SpatVector object.

ngroups

integer(1). The number of groups.

padding

numeric(1). A extrusion factor to make buffer to clip actual datasets. Depending on the length unit of the CRS of input.

Value

A list of two,

  • original: exhaustive and non-overlapping grid polygons in the class of input

  • padded: a square buffer of each polygon in original. Used for computation.

Author

Insang Song

Examples

library(terra)
library(sf)
ncpath <- system.file("gpkg/nc.gpkg", package = "sf")
nc <- terra::vect(ncpath)
nc_rp <- terra::spatSample(nc, 1000)
nc_gr <- par_group_grid(nc_rp, 10L, 1000)
nc_gr
#> $original
#>  class       : SpatVector 
#>  geometry    : points 
#>  dimensions  : 1000, 15  (geometries, attributes)
#>  extent      : -84.25836, -75.48334, 33.95281, 36.56051  (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.121     1.855  2107    2107 Richmond 37153 3.715e+04       77
#>                 0.19     2.204  1846    1846  Halifax 37083 3.708e+04       42
#>                0.118     1.601  1946    1946  Madison 37115 3.712e+04       58
#>  BIR74 SID74 (and 5 more)
#>  <num> <num>             
#>   2756     4             
#>   3608    18             
#>    765     2             
#> 
#> $padded
#>  class       : SpatVector 
#>  geometry    : polygons 
#>  dimensions  : 10, 1  (geometries, attributes)
#>  extent      : -1084.258, 924.5167, -966.0472, 1036.561  (xmin, xmax, ymin, ymax)
#>  coord. ref. :  
#>  names       : CGRIDID
#>  type        :   <num>
#>  values      :       1
#>                      2
#>                      3
#>