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 14 forks source link

Unable to load las or laz files #53

Closed denzle83 closed 2 years ago

denzle83 commented 2 years ago

Hi,

I'm having trouble opening my las files. Where just last week everything was fine, now nothing seems to load. I've moved files from my own dir to the lidR one, have compressed the files to LAZ and tried every conceivable method to load them but either receive:

I've searched for any information relating to the 'Invalid header' but find nothing of help. I have updated R and RStudio to the latest as well uninstalling and re-installing everything and installing an older version. Also renaming the files to see if that has any impact but nothing seems to work. Do you have any ideas what could be the cause?

Many thanks Dan

Jean-Romain commented 2 years ago

Can you share the file ?

denzle83 commented 2 years ago

Many thanks for your quick reply. I've left a OneDrive link for the las files, if you have any problems accessing it or use a different drive just let me know i'll add them to your preferred cloud.

I have found that using read.las instead of readLAS seems to allow files to be opened but then unable to run any other functions ie classify ground or normalise.

https://1drv.ms/u/s!AsVBoyyYmzOCgjvpNXNAKIMOY4xl?e=Z7uHvA

Regards Dan

Jean-Romain commented 2 years ago

I have a different issue.

 Error in nchar(extra_byte[["description"]]) : 
  invalid multibyte string, element 1 

Anyway it is an issue with rlas. I think it badly reads a 32 characters string that is not NUL-terninated . Reproducible example:

h = rlas::read.lasheader("hen_faes_plot3_lidar.laz")
h
#>  [...]
#> $`Variable Length Records`$Extra_Bytes$`Extra Bytes Description`$NormalZ$description
#> [1] "Z component of a vector normal t0\032\0056\xfc\177"

Moved to rlas

Jean-Romain commented 2 years ago

Two workarounds in lidR before I find a fix.

Do not read extra bytes

This way the header will be modified to remove information about extra bytes and it will consequently not trigger any error

las = readLAS("hen_faes_plot3_lidar.laz", select = "-0")

Create a LAS object manually

p = rlas::read.las("hen_faes_plot3_lidar.laz", filter = "-keep_random_fraction 0.01")
h = rlas::read.lasheader("hen_faes_plot3_lidar.laz")
h$`Variable Length Records`$Extra_Bytes$`Extra Bytes Description`$NormalZ$description = "Z component of a vector normal t"
las = LAS(p, h)
denzle83 commented 2 years ago

Thank you for the work arounds they are a great help and greatly appreciated.

Dan

Jean-Romain commented 2 years ago

The bug is expected to be fixed. Please install rlas 1.5.1 and tell me if it works well