2

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.

1 Answer 1

3

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.

6
  • Thank you for the detailed answer. Since, the output file would be too big to load into R. Can I clip an ROI from it by just using readLAScatalog? Commented Sep 2, 2022 at 20:25
  • 1
    Yes, but the file will be so big that it will take a significant amount of time. You must create a spatial index to perform spatial query in a reasonable time-frame. Merging 110 file into a single one is a bad idea in all aspect actually.
    – JRR
    Commented Sep 3, 2022 at 10:21
  • true, but the problem is that ESRI gave us height normalized LAS files for our county. And ESRI put the files into 4 folders, only one of those folders is for 1 city out of 31 other cities. The rest of the LAS files were put under folders SectionNE, SectionNW and SectionS respectively. On top of that ESRI used their own naming convention so I have no idea what's the location of a tile by reading the filename. I also don't know how ESRI did the tiling. Hence basically I am stiching them up to extract ROIs for cities, parks and conservation areas. Commented Sep 3, 2022 at 18:35
  • So first I will stitch them all up to have a single file for the county, then clip cities out of it one by one. And then from cities I will extract parks and other areas of interest. Commented Sep 3, 2022 at 18:38
  • 1
    This sound overly complex. You could simply use you lascatalog with files from different folders. It is not a problem. You can also retile in 1x1 km tiles with custom name convention. Both options are better than one big 100 GB file
    – JRR
    Commented Sep 3, 2022 at 18:43

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.