4

I frequently use the package 'lidR' to do forest point cloud analysis and the package functions OK, just I noticed that every time I load in point clouds using Rstudio, the file sizes seem to be much larger than they should be. The code to load in the files is simple, such as:

library(lidR)

lashome <-('C:/Directoryname')
setwd(lashome)

#input las files
UASfile <- ('UAS_1cm_aligned.las')

#read las file
las = lidR::readLAS(UASfile, select = "*+")

The question is, why is the filesize reported as 1.8GB in Rstudio when the actual filesize is 695MB? Is this an Rstudio glitch that I should just ignore?

filesize

5

In the best world the memory allocated to load a las file should be almost equal to the size of the file. But this is not possible especially in R. This is explained in this vignette.

It is important to note that R only enables manipulation of 32-bit integers and 64-bit decimal numbers. But the las specification states, for example, that the intensity is stored on 16 bits (see previous sections). When read in R it must be converted to 32 bits and therefore will use twice as much memory than is needed. Worse, the return numbers are stored on 3 bits in las files but 32 bits in R, therefore using 11 times more memory than is required. Last but not least, flags are stored on 1 bit, whereas R uses 32 bits. This is 32 times more memory than is needed. As a consequence, a LAS object is 2 to 3 times larger than it needs to be.

This is why we introduced the option select. See the vignette.

  • This makes sense! So if I'm not concerned with the return number or intensity values I should use select to avoid loading them in. – Cory G. Oct 16 at 22:16
  • In short, yes! I suggest you to read the whole vignette (and the other vignette too btw) – JRR Oct 16 at 22:24
2

R is reporting the size of the object in memory, not the size of the file.

If you run the example from readLAS you'll get las which is:

> las
class        : LAS (LASF v1.2)
point format : 1
memory       : 5.6 Mb

this size depends on which parts of the file you read in (via the select and other options) and how much the LAS file is compressed.

Most lidar files use a compression algorithm (like a ZIP file) to make the file much smaller than the uncompressed data which R needs in order to work with it.

  • This is not really correct. las files are not compressed. The format cleverly optimize the number of bit used to store the payload but without compression scheme. laz files are compressed. – JRR Oct 16 at 22:14

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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