convert_raster: Raster format conversion

View source: R/common.R

convert_rasterR 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| stars" to get an output in SpatRaster 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
# convert_raster(chm_stars, pkg = "terra")
# }

lidaRtRee documentation built on April 3, 2025, 10:29 p.m.