Returns a data frame with one row per tile in a [grout()] scheme, giving the GDAL-style pixel offset (`offset_x`, `offset_y`), the actual pixel dimensions of each tile (`ncol`, `nrow`), and the geographic extent.
tile_index(x, tile = NULL, clip = TRUE)a `"grout_tiles"` object from [grout()].
optional integer vector of 1-based tile indices to return. The default `NULL` returns every tile in row-major order. Values may be given in any order and may repeat; one row is returned per element, in the order supplied.
clip the edge tiles to the pixels that exist (the default), or with `FALSE` report every tile at the full block size.
a [tibble::tibble()].
Tiles along the right or bottom edge may be smaller than the block size when there is a "dangle" (the raster dimensions are not an exact multiple of the block size). By default those tiles are clipped to the pixels that actually exist, which is what a windowed read wants. With `clip = FALSE` every tile reports the full block size and the edge tiles extend past the grid, which is what a chunk of a tiled format actually occupies on disk - a GDAL block or a Zarr chunk at the margin is a whole block, padded. The unclipped counts are not recoverable from the clipped index, so this has to be asked for when the index is built.
Every column is a function of the tile index and the scheme, so the index does not have to be materialized in full. Pass `tile` to evaluate only the tiles wanted, in the order wanted; the rows returned are identical to `tile_index(x)[tile, ]` but are computed directly rather than by building and subsetting the whole table. This matters for schemes with many tiles, where the full index is large but the tiles of interest are few.
Column layout: * `tile` - 1-based tile index (row-major, left-to-right top-to-bottom). * `offset_x`, `offset_y` - 0-based pixel offsets from the top-left corner of the raster, suitable for passing directly to GDAL `ReadRaster()`. * `tile_col`, `tile_row` - 1-based tile grid coordinates. * `ncol`, `nrow` - pixel dimensions of this tile. * `xmin`, `xmax`, `ymin`, `ymax` - geographic extent of this tile.
g <- grout(c(87, 61), extent = c(0, 1, 0, 1), blocksize = c(32L, 16L))
tile_index(g)
#> # A tibble: 12 × 11
#> tile offset_x offset_y tile_col tile_row ncol nrow xmin xmax ymin ymax
#> <int> <int> <dbl> <int> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl>
#> 1 1 0 0 1 1 32 16 0 0.368 0.738 1
#> 2 2 32 0 2 1 32 16 0.368 0.736 0.738 1
#> 3 3 64 0 3 1 23 16 0.736 1 0.738 1
#> 4 4 0 16 1 2 32 16 0 0.368 0.475 0.738
#> 5 5 32 16 2 2 32 16 0.368 0.736 0.475 0.738
#> 6 6 64 16 3 2 23 16 0.736 1 0.475 0.738
#> 7 7 0 32 1 3 32 16 0 0.368 0.213 0.475
#> 8 8 32 32 2 3 32 16 0.368 0.736 0.213 0.475
#> 9 9 64 32 3 3 23 16 0.736 1 0.213 0.475
#> 10 10 0 48 1 4 32 13 0 0.368 0 0.213
#> 11 11 32 48 2 4 32 13 0.368 0.736 0 0.213
#> 12 12 64 48 3 4 23 13 0.736 1 0 0.213
## only the tiles wanted, in the order wanted
tile_index(g, tile = c(4, 1, 9))
#> # A tibble: 3 × 11
#> tile offset_x offset_y tile_col tile_row ncol nrow xmin xmax ymin ymax
#> <int> <int> <dbl> <int> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl>
#> 1 4 0 16 1 2 32 16 0 0.368 0.475 0.738
#> 2 1 0 0 1 1 32 16 0 0.368 0.738 1
#> 3 9 64 32 3 3 23 16 0.736 1 0.213 0.475
## full blocks, including the dangle past the grid edge
tile_index(g, clip = FALSE)
#> # A tibble: 12 × 11
#> tile offset_x offset_y tile_col tile_row ncol nrow xmin xmax ymin
#> <int> <int> <dbl> <int> <dbl> <int> <int> <dbl> <dbl> <dbl>
#> 1 1 0 0 1 1 32 16 0 0.368 0.738
#> 2 2 32 0 2 1 32 16 0.368 0.736 0.738
#> 3 3 64 0 3 1 32 16 0.736 1.10 0.738
#> 4 4 0 16 1 2 32 16 0 0.368 0.475
#> 5 5 32 16 2 2 32 16 0.368 0.736 0.475
#> 6 6 64 16 3 2 32 16 0.736 1.10 0.475
#> 7 7 0 32 1 3 32 16 0 0.368 0.213
#> 8 8 32 32 2 3 32 16 0.368 0.736 0.213
#> 9 9 64 32 3 3 32 16 0.736 1.10 0.213
#> 10 10 0 48 1 4 32 16 0 0.368 -0.0492
#> 11 11 32 48 2 4 32 16 0.368 0.736 -0.0492
#> 12 12 64 48 3 4 32 16 0.736 1.10 -0.0492
#> # ℹ 1 more variable: ymax <dbl>
## edge case: one tile
tile_index(grout(c(61, 87), blocksize = c(61L, 87L)))
#> # A tibble: 1 × 11
#> tile offset_x offset_y tile_col tile_row ncol nrow xmin xmax ymin ymax
#> <int> <int> <dbl> <int> <dbl> <int> <int> <dbl> <dbl> <dbl> <dbl>
#> 1 1 0 0 1 1 61 87 0 61 0 87