| mosaic | R Documentation |
Combines several .vec rasters that share a resolution and cell grid into one
raster spanning their union, resolving overlap with fun. The output is
walked one tile-row strip at a time and each input contributes only the window
overlapping the current strip, so neither the inputs nor the output are held
whole in memory.
mosaic(
rasters,
fun = c("first", "last", "mean", "sum", "min", "max"),
band = 1L,
path = NULL,
dtype = "f32",
compression = c("fast", "balanced", "max")
)
rasters |
A list of |
fun |
Overlap rule where inputs cover the same cell: |
band |
Band read from every input (1-based). Default 1. |
path |
Optional output |
dtype |
Storage dtype for |
compression |
Compression effort for |
This is the monoid fold tier of the spatial toolbox: each output strip folds
the overlapping input windows, bounded memory, no spill. The inputs must share
resolution and lie on a common cell grid; warp() them onto a shared grid
first if they do not. No sf is needed.
When path is NULL, a numeric matrix on the union grid (row 1
northmost) carrying gt, extent, and crs attributes. When path is
given, the written vectra_raster handle (invisibly).
warp() to bring rasters onto a shared grid, rast_calc() for
cellwise combination of already-aligned rasters.
a <- matrix(1, 4, 4); b <- matrix(2, 4, 4)
fa <- tempfile(fileext = ".vec"); fb <- tempfile(fileext = ".vec")
vec_write_raster(a, fa, dtype = "f64", extent = c(0, 0, 4, 4))
vec_write_raster(b, fb, dtype = "f64", extent = c(2, 2, 6, 6))
m <- mosaic(list(fa, fb), fun = "mean")
dim(m)
unlink(c(fa, fb))
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.