mosaic_chm | R Documentation |
This function calculates the canopy height model (CHM) and the volume for a given digital surface model (DSM) raster layer. Optionally, a digital terrain model (DTM) can be provided or interpolated using a set of points or a moving window.
mosaic_chm(
dsm,
dtm = NULL,
points = NULL,
interpolation = c("Tps", "Kriging"),
window_size = c(10, 10),
mask = NULL,
mask_soil = TRUE,
verbose = TRUE
)
dsm |
A |
dtm |
(optional) A |
points |
(optional) An |
interpolation |
(optional) A character string specifying the
interpolation method to use when |
window_size |
An integer (meters) specifying the window size (rows and columns, respectively) for creating a DTM using a moving window. Default is c(10, 10). |
mask |
(optional) A |
mask_soil |
Is |
The function first checks if the input dsm
is a valid single-layer
SpatRaster
object. If dtm
is not provided, The function generates a
Digital Terrain Model (DTM) from a Digital Surface Model (DSM) by
downsampling and smoothing the input raster data. It iterates over the DSM
matrix in windows of specified size, finds the minimum value within each
window, and assigns these values to a downsampled matrix. After downsampling,
the function applies a mean filter to smooth the matrix, enhancing the visual
and analytical quality of the DTM. Afterwards, DTM is resampled with the
original DSM.
If both dsm
and dtm
are provided, the function ensures they have the same
extent and number of cells, resampling dtm
if necessary. The CHM is then
calculated as the difference between dsm
and dtm
, and the volume is
calculated by multiplying the CHM by the pixel size. The results are
optionally masked using the provided mask
.
A SpatRaster
object with three layers: dtm
(digital terrain
model), height
(canopy height model), and volume
.
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.