r-lidar / rlas

R package to read and write las and laz files used to store LiDAR data
https://cran.r-project.org/package=rlas
GNU General Public License v3.0
34 stars 15 forks source link

R crashes when reading in laz files with lidR #56

Open AndresKasekamp opened 2 years ago

AndresKasekamp commented 2 years ago

I have problem with reading in laz files from one of the flight years from my NMA. It causes RStudio to crash without any messages. All the other years work perfectly and I can easily apply functions to it. Using the erroneous laz files in LASTools has not produced any errors. I am using the latest lidR version.

It is probably related to https://stackoverflow.com/questions/60457539/lidr-readlas-function-crashes-r-when-reading-some-las-files .

I am attaching a Google Drive link with the error and no error laz files. https://drive.google.com/drive/folders/1SVsfenH_petxogLg7-QvBaeQ98aHrDvj?usp=sharing

Jean-Romain commented 2 years ago

This is not related to lidR. Moved to rlas

library(rlas)
las = read.las("issue 574/no_error.laz")
AndresKasekamp commented 2 years ago

I managed to solve the problem. The erroneous laz had Extra Byte attributes Amplitude and Pulse width. The no error laz had Amplitude, Pulse width, Reflectance and Deviation. They are numbered 1-4 accordingly. By specifying which attributes to read in (or not to read in), RStudio did not crash anymore. For example

 las <- readLAS(r"(laz_check\error.laz)", select = "xyzia")

lidR reads every attribute in by default. However, it it is interesting that my error.laz had attributes Amplitude and Pulse width, but I cannot use them. The error.laz Amplitude did have a different type than no_error.laz (4 (short) vs 3 (unsigned short)). However, Pulse width had the same data type and using "xyzia2" still causes RStudio to crash.

Jean-Romain commented 2 years ago

Thanks for the investigation. This helps to narrow down the potential issues.