View source: R/tree_detection.R
cimg2Raster | R Documentation |
converts a cimg object to a SpatRaster object
cimg2Raster(cimg, r = NULL)
cimg |
raster object. raster of canopy height model, preferably filtered to avoid effect of holes on volume and surface computation |
r |
SpatRaster object. defines the extent and projection of conversion result |
A SpatRaster object
raster2Cimg
data(chm_chablais3)
chm_chablais3 <- terra::rast(chm_chablais3)
# convert raster to cimg object
chm_cim <- raster2Cimg(chm_chablais3)
# apply filtering
chm_cim_filt <- dem_filtering(chm_cim,
nl_filter = "Closing",
nl_size = 3,
sigma = 0
)$non_linear_image
# convert to SpatRaster
chm_filt <- cimg2Raster(chm_cim_filt, chm_chablais3)
# plot SpatRaster
terra::plot(chm_chablais3)
# plot cimg object
plot(chm_cim)
# plot filtered cimg object
plot(chm_cim_filt)
# plot filtered SpatRaster
terra::plot(chm_filt)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.