Learn R Programming

lidaRtRee (version 4.0.8)

convert_raster: 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)

Value

A raster object in the specified format

Arguments

r

raster object or file name.

pkg

package name. Use pkg = "terra| stars" to get an output in SpatRaster or stars format

Examples

Run this code
# 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
# convert_raster(chm_stars, pkg = "terra")
# }

Run the code above in your browser using DataLab