Applies a moving window to a .vec raster, reading the input one tile-row
strip at a time – each strip expanded by the kernel radius (a halo read) so
window neighbours are available without ever holding the whole grid resident.
The per-window statistic is computed in C. When path is given the output is
streamed straight back to a new .vec one tile-row at a time, so neither the
input nor the output band is ever fully in memory; this is the raster op that
runs out of core where an in-memory engine needs the whole raster at once.
Arguments
- x
A
vectra_raster(fromvec_open_raster()) or a path to a.vecraster.- w
A numeric weight matrix with odd dimensions, or a single positive odd integer
kfor ak x kwindow of ones. Defaultmatrix(1, 3, 3).- fun
Window statistic: one of
"sum","mean","min","max","sd","median". Default"mean".- na.rm
Skip nodata cells inside the window (
TRUE, default) or let them propagateNA(FALSE).- band
Band to read (1-based). Default 1.
- path
Optional output
.vecpath. When given the result is streamed to disk and the openedvec_open_raster()handle is returned invisibly; whenNULLthe result is returned as an in-memory matrix.- dtype
Storage dtype for
.vecoutput (seevec_write_raster()). Default"f32".- compression
Compression effort for
.vecoutput. Default"fast".
Value
When path is NULL, a numeric matrix (row 1 northmost) carrying
gt, extent, crs, and fun attributes. When path is given, the
written vectra_raster handle (invisibly).
Details
This is the sort / partition tier of the spatial toolbox: bounded to one haloed strip at a time, exploiting tile locality.
The window w is a numeric weight matrix with odd dimensions (or a single
odd integer k, shorthand for a k x k matrix of ones). NA weights mark
cells outside the window. For fun = "sum"/"mean" the weights scale the
values (sum is sum(w * x), mean is sum(w * x) / sum(w)); for the other
statistics a finite weight only marks membership. With na.rm = TRUE (the
default) nodata cells inside the window are skipped; with na.rm = FALSE any
nodata cell – including a window that runs off the raster edge – makes the
result NA, matching the resident behaviour.