assuming snapped here, some kind of refactor is required
library(filearchy)
library(dplyr)
dsn <- system.file("extdata/gebco_ovr5.vrt", package = "filearchy", mustWork = TRUE)
## parallelize here
#future::plan(multicore)
tiles <- gdal_tiles(dsn, dry_run = TRUE)
tiles |> filter(zoom == 1)
profile <- filearchy:::tile_profile()
g <- grout::grout(c(512, 512), profile$extent, blocksize = c(256, 256))
grout::tile_zoom
vaster::col_from_cell
## we are already snapped to the output tiling, no dangle here
tile_index0 <- function(dimension, extent = NULL, block = 256) {
block <- rep(block, length.out = 2L)
nc <- prod(dimension)
tile <- seq_len(nc)
offsetX <- (vaster::col_from_cell(dimension, tile) - 1) * block[1]
offsetY <- (vaster::row_from_cell(dimension, tile) - 1) * block[2]
nX <- rep(block[1], nc)
nY <- rep(block[2], nc)
res <- diff(extent)[c(1, 3)] / dimension
minX <- extent[1] + offsetX * res[1]
maxX <- extent[1] + (offsetX + nX) * res[1]
minY <- extent[4] + (offsetY + nY) * -res[2]
maxY <- extent[4] + offsetY * -res[2]
tile_col <- (offsetX %/% block[1]) + 1
tile_row <- (offsetY %/% block[2]) + 1
tibble::tibble(tile = tile, offset_x = offsetX, offset_y = offsetY,
tile_col = tile_col, tile_row = tile_row,
ncol = nX, nrow = nY, xmin = minX, xmax = maxX, ymin = minY, ymax = maxY)
}
tile_index0(c(256, 256), profile$extent)
assuming snapped here, some kind of refactor is required