convert_raster {lidaRtRee} | R Documentation |
Raster format conversion
Description
Function to convert between raster formats. Use pkg = "terra|raster|stars" to get an output in SpatRaster, RasterLayer or stars format. Default is getOption("lidR.raster.default").
Usage
convert_raster(r, pkg = NULL)
Arguments
r |
raster object or file name. |
pkg |
package name. Use pkg = "terra| raster|stars" to get an output in SpatRaster, RasterLayer or stars format |
Value
A raster object in the specified format
Examples
# load SpatRaster
data(chm_chablais3)
chm_chablais3 <- terra::rast(chm_chablais3)
# convert only if packages stars and raster are installed
# if (require("stars"))
# {
# to stars
# chm_stars <- convert_raster(chm_chablais3, pkg = "stars")
# chm_stars
# }
if (require("raster"))
{
# to raster
chm_raster <- convert_raster(chm_chablais3, pkg = "raster")
chm_raster
# back to terra
convert_raster(chm_raster, pkg = "terra")
}
[Package lidaRtRee version 4.0.5 Index]