Given a grid (dimension + extent), compute how it maps onto tiles of a given block size. The result records the tile count in each dimension and the "dangle" - the number of extra pixels that arise when the grid dimensions do not divide evenly into the block size.
grout(
dimension,
extent = NULL,
blocksize = c(256L, 256L),
projection = NA_character_
)integer vector `c(ncol, nrow)` of the raster grid.
numeric vector `c(xmin, xmax, ymin, ymax)`. Defaults to `c(0, ncol, 0, nrow)` (pixel-coordinate space).
integer vector `c(block_ncol, block_nrow)`. Defaults to `c(256L, 256L)`.
CRS string (e.g. `"EPSG:4326"`). Stored but not used computationally.
A `"grout_tiles"` object: a list with * `$tileraster` - grid spec (`dimension`, `extent`, `projection`) of the *tile* grid (one cell per tile). * `$scheme` - internal `"grout_tilescheme"` with block sizes, tile counts, and dangle values.
Use [tile_index()] to turn the scheme into a data frame of pixel offsets and spatial extents, one row per tile.
[tile_index()], [tile_spec()]
## clean fit
grout(c(16, 12), extent = c(0, 16, 0, 12), blocksize = c(4L, 4L))
#> tiles: 4 x 3 (12 total)
#> block: 4 x 4
#> dangle: 0, 0 (col, row)
#> tile resolution: 4 x 4
#> tile extent: 0, 16, 0, 12 (xmin,xmax,ymin,ymax)
## dangle in both dimensions
grout(c(15, 13), extent = c(0, 15, 0, 13), blocksize = c(4L, 4L))
#> tiles: 4 x 4 (16 total)
#> block: 4 x 4
#> dangle: 1, 3 (col, row)
#> tile resolution: 4 x 4
#> tile extent: 0, 16, -3, 13 (xmin,xmax,ymin,ymax)
## default pixel-coordinate extent
grout(c(87, 61), blocksize = c(12L, 16L))
#> tiles: 8 x 4 (32 total)
#> block: 12 x 16
#> dangle: 9, 3 (col, row)
#> tile resolution: 12 x 16
#> tile extent: 0, 96, -3, 61 (xmin,xmax,ymin,ymax)