
Build a lazy patch dataset over a terra::SpatRaster
Source: R/foundation_tiles.R
foundation_tile_dataset.RdReturns an edaphos_tile_dataset S3 object that knows how to sample
batched (B, C, H, W) tensors from the underlying raster on demand
– without ever loading the whole mosaic into memory. The dataset
is what foundation_moco_pretrain_tiles() consumes.
Usage
foundation_tile_dataset(
stack,
patch_size = 16L,
n_patches = 1000L,
valid_mask = NULL,
normalise = TRUE,
seed = NULL
)Arguments
- stack
A
terra::SpatRasterwith the channels to sample.- patch_size
Integer – spatial side of each patch.
- n_patches
Integer – total number of patches the dataset should expose. Sampling is with replacement when
n_patches > total valid cells.- valid_mask
Optional
terra::SpatRasterof 0/1 defining which cells are eligible as patch centres.- normalise
Logical – if
TRUE(default) each channel is standardised to zero mean / unit standard deviation based on the raster's global statistics.- seed
Optional integer for reproducibility.