Converts a voxel space (i, j) layer into a terra::SpatRaster object.

toRaster(vxsp, vx)

Arguments

vxsp

a VoxelSpace object.

vx

a voxel space horizontal slice. A data.table with i, j columns and least one additional variable, the value of the raster layer. Every column beside i and j will be converted into a raster layer.

Value

a terra::SpatRaster object.

Examples

if (FALSE) {
vxsp <- readVoxelSpace(system.file("extdata", "tls_sample.vox", package = "AMAPVox"))
library(terra)

# CHM, DEM and PAI as raster
plot(toRaster(vxsp, merge(canopyHeight(vxsp), groundElevation(vxsp), all = T)))

# PAI
vxsp <- plantAreaDensity(vxsp)
pai <- plantAreaIndex(vxsp, type = "xy", pattern.pad = "pad_transmittance")
plot(toRaster(vxsp, pai))

# sampling intensity at 2 meters
plot(toRaster(vxsp, vxsp@data[ground_distance == 2.25, .(i, j, nbSampling)]))
}