2

I want to save multiple height normalized .laz files as variables to my global environment in R, but the readLAS() function starts decompressing the .laz files, and there comes a point where my laptop can no longer allocate more RAM to R for storing variables. I tried using reducing the size of a laz file variable by using the select function select = "xyz0" according to this question, which has reduced the size to 428 MB which was initially increased to 1.6 GB (without the select function) from 78.4 MB (original .laz file size).

Can I use the filter function to exclude anything else from the .laz file in order to further reduce the variable size, when the purpose is to create convex hull polygons? Basically, I want to reduce memory allocation size due to the way R stores LAS/LAZ files as variables.

1
  • It would be a nice feature if R uses the hard drive to temporarily store global environment variables especially with SSDs, which are so much faster than traditional HDDs. Aug 10, 2020 at 23:21

1 Answer 1

1

You already found the best option to reduce the loaded memory. If you read carefully the vignette linked in the question you mentioned you also understood why reading a LAS files in R uses so much memory and you understood that there is nothing we can do. So, spoiler alert, you won't be able to load a lot of data at once. So what are the options?

Use select in readLAS to drop unused attributes: you already found that one but for completeness of the answer I'm saying it again. This is the simplest way to reduce the amount of memory loaded

Use filter in readLAS to drop unused points: for example you may want to work only with first returns readLAS("file.las", filter = "-keep_first").

Use the LAScatalog engine: to apply your routine one LAS file at a time and automatically save the outputs in files. If loading one file is still too much the engine has the capability to work with smaller chunks (e.g. 500 x 500 m). LAScatalog engine is the answer to your question but is an advanced tool. We wrote a lot of resources about this feature

  • A vignette that documents the engine
  • A book chapter that introduce the LAScatalog with more examples and images. It is more a tutorial than a manual
  • Another vignette that shows how to apply a user-defined routine
  • Another book chapter that introduce how to apply user-defined function with more examples and images. It is more a tutorial than a manual

My advice is to read the book first because it is more like a simplified and illustrated tutorial while vignettes are more like a comprehensive documentation and are less user-friendly.

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.