Create a grid of square-shaped windows
create_grid(x, size, shift = NULL)
A SpatRaster
Expressed in the numbers of cells, is a length of the side of a square-shaped block of cells. It defines the extent of a local pattern. If size=NULL
calculations are perfomed for the whole area
Defines the shift between adjacent squares of cells along with the N-S and W-E directions. It describes the density (resolution) of the output grid. The resolution of the output map will be reduced to the original resolution multiplied by the shift. If shift=size the input map will be divided into a grid of non-overlapping square windows. Each square window defines the extent of a local pattern. If shift < size - results in the grid of overlapping square windows.
An sf polygon object
library(terra)
race_raster = rast(system.file("extdata/race_raster.tif", package = "raceland"))
x = create_realizations(race_raster, 1)
y = create_grid(x, size = 10)
y
#> Simple feature collection with 36 features and 2 fields
#> Geometry type: POLYGON
#> Dimension: XY
#> Bounding box: xmin: 685545 ymin: 2103255 xmax: 687345 ymax: 2105055
#> Projected CRS: USA_Contiguous_Albers_Equal_Area_Conic
#> First 10 features:
#> row col geom
#> 1 1 1 POLYGON ((685545 2105055, 6...
#> 2 1 2 POLYGON ((685845 2105055, 6...
#> 3 1 3 POLYGON ((686145 2105055, 6...
#> 4 1 4 POLYGON ((686445 2105055, 6...
#> 5 1 5 POLYGON ((686745 2105055, 6...
#> 6 1 6 POLYGON ((687045 2105055, 6...
#> 7 2 1 POLYGON ((685545 2104755, 6...
#> 8 2 2 POLYGON ((685845 2104755, 6...
#> 9 2 3 POLYGON ((686145 2104755, 6...
#> 10 2 4 POLYGON ((686445 2104755, 6...