
Apply a fitted MoCo v2 encoder over a full raster mosaic
Source:R/foundation_moco.R
foundation_moco_embed_raster.RdSlides a patch_size x patch_size window over the input raster at
stride stride, extracts each patch, encodes it with the
backbone of moco$encoder_q, and writes the resulting embedding
vector back as a multi-layer terra::SpatRaster whose layer count
equals moco$feature_dim. Patches whose centre cell is NA in the
input produce an NA row in the output.
Usage
foundation_moco_embed_raster(
moco,
stack,
dataset,
patch_size = NULL,
stride = NULL,
projection = FALSE
)Arguments
- moco
An
edaphos_foundation_mocoreturned byfoundation_moco_pretrain_tiles().- stack
A
terra::SpatRasterwith the same channel order as the one used at training time.- dataset
The
edaphos_tile_datasetused at training time (provides the per-channel normalisation statistics).- patch_size
Integer – must equal
dataset$patch_size.- stride
Integer step size of the sliding window (default half of
patch_size).- projection
Logical – if
TRUEreturn the L2-normalised projection-head outputs instead of the backbone features.
Value
A terra::SpatRaster with feature_dim (or proj_dim)
layers.