R lidR stitching several LAS files into one

lidrr

I have 110 LAS files for a county, and I would like to stitch/combine them all into one single LAS file and write it to disk without bringing it into R. Since, each LAS file when imported into R has a size of 1.7 GB, I am looking for a way to combine these files without having to import them into R or maybe there is another way.

Code:

# Import the list of LAS files in the folder
FL_LAS_List = readLAScatalog("//path")

How can I do this?

I did find this question:

Merge all tiles from lascatalog?

Code in the answer:

opt_output_files(ctg) <- "folder/singlefilename"
opt_chunk_buffer(ctg) <- 0
opt_chunk_size(ctg) <- 10000
singlefile_ctg <- catalog_retile(ctg)

However, I do have some questions.

  1. Why are opt_chunk_buffer(ctg) <- 0 opt_chunk_size(ctg) <- 10000 being added? And why the value 0 and 10000?
  2. And this singlefile_ctg <- catalog_retile(ctg) will write the merged LAS file into the same folder as given in ctg = readLAScatalog("folder/")? Because my output path is different from the input folder.

On a side note when I run readLAScatalog(), I get the following warning, I don't know if this is going to be an issue while merging the files.

Be careful, some tiles seem to overlap each other. lidR may return incorrect outputs with edge artifacts when processing this catalog.

Best Answer

Why are opt_chunk_buffer(ctg) <- 0 opt_chunk_size(ctg) <- 10000 being added? And why the value 0 and 10000?

When processing a LAScatalog you define a chunk size to process sequentially small chunks that fit in memory. Your chunks can be smaller than your tiles, the size of your tiles or bigger than you tiles. If you put a number bigger than the size of your collection it mean that it processes everything at once into a single massive chunk. Here the value 10000 is totally arbitrary. You can put 100000. Just put a number big enough such as only one chunk is generated.

The buffer is 0 because you don't need to load redundant data between the chunks. Anyway there is only one chunk. If what I'm saying is not clear, I suggest reading this chapter of the book.

And this singlefile_ctg <- catalog_retile(ctg) will write the merged LAS file into the same folder as given in ctg = readLAScatalog("folder/")? Because my output path is different from the input folder.

No. It will write into folder/singlefilename.las. Again read the book chapter linked.

On a side note when I run readLAScatalog(), I get the following warning, I don't know if this is going to be an issue while merging the files.

It depends if there are duplicated points. If two files overlap and each one contains a subset of points that can be found in both files (typically files in which a buffer has been added) yes it is a problem. If the bounding boxes overlap but the actual point cloud is continuous without duplicated region it is not a problem.

Related Question