0

This question can be considered an extension of Create a DTM using the TIN algorithm

I am providing multiple LAS files as a catalog list to the rasterize_terrain which breaks the LAS into smaller chunks and returns DTM .tif rasters for each chunk.

The I have to use the terra package to merge these smaller DTM rasters into one big raster. Now is there a way to directly get a single DTM raster using just the lidR package? Or is there a better way to do this or is my current code the correct approach?

I did try merging (catalog_retile() function) all input LAS files into a single LAS to get a single DTM raster, however rasterize_terrain failed with an interpolation error. So, I guess it is best to use multiple LAS files.

Current code:

library(lidR)
library(terra)
 
# Create a LAS catalog
LAS_List = readLAScatalog("path", recursive = TRUE)

# Create an output destination to store the DTM raster files
opt_output_files(LAS_list) <-  paste0("folder/{*}_dtm")

# Create a DTM using the TIN method
dtm_tin = rasterize_terrain(LAS_List, res = 1, algorithm = tin())

# Create a list of rasters and store their path
FL_DTMs_List = list.files(getwd(), "tif$", full.names=TRUE) # the $ exludes aux-files

# Create a SpatRasterCollection using the terra package
DTM_ic = sprc(lapply(FL_DTMs_List, rast))

# Merge these DTMs into a single raster
terra::merge(DTM_ic, filename = "path/DTM/DTM.tif") 

1 Answer 1

2

It is not possible in lidR and it is not useful. You have multiple raster files and a virtual raster mosaic file to "glue" them. Any decent gis software including R is able to handle virtual raster mosaic as a single raster. If you really want a single raster file then you can use terra::writeRaster.

terra::writeRaster(dtm_tin, "path/DTM/DTM.tif")

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.