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)

Arguments

x

a `"grout_tiles"` object from [grout()].

Value

a [tibble::tibble()].

Details

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).

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.

Examples

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

## 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