Why are .las file sizes inflated when read using package 'lidR' via Rstudio?

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.


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.

Tags:

R

Lidar

Lidr