Skip to contents

Splits a large `SpatRaster` into fixed-size tiles with optional overlap (buffer) and writes each tile to disk. Tiles are generated deterministically in row-column order and accompanied by metadata describing their spatial layout and buffered extents.

Usage

make_tiles_disk(
  x,
  tile_size = 2048,
  buffer = 64,
  prefix = "tile",
  dir = tempdir(),
  overwrite = TRUE,
  verbose = TRUE
)

Arguments

x

A `SpatRaster` to be tiled.

tile_size

Integer. Size (in pixels) of each tile along rows and columns (excluding buffer).

buffer

Integer. Number of pixels added as overlap on all sides of each tile.

prefix

Character. Filename prefix for generated tile files.

dir

Character. Output directory where tiles will be written.

overwrite

Logical. Whether to overwrite existing tile files.

verbose

Logical. If `TRUE`, display progress information.

Value

A `data.frame` with one row per tile and the following columns:

tile_id

Sequential tile identifier.

file

Path to the tile raster on disk.

r0_in, r1_in

Row indices of the inner (unbuffered) tile.

c0_in, c1_in

Column indices of the inner (unbuffered) tile.

r0_buf, r1_buf

Row indices including buffer.

c0_buf, c1_buf

Column indices including buffer.

buffer

Buffer size (in pixels).

Details

This function is designed for scalable, disk-backed segmentation workflows where large rasters must be processed tile-by-tile while preserving spatial consistency at tile borders.

Tiles are cropped using spatial extents derived from row/column indices, snapped to the raster grid to avoid rounding artifacts. Output rasters are written using tiled GeoTIFF with LZW compression and safe BigTIFF handling.

Empty tiles (with no values) are skipped. An error is raised if no tiles are produced.

See also