Gitmaxwell / lastools

‘lastools’ is an R package for reading and writing version 1.2 and version 2.0 Log ASCII Standard (LAS) and for performing common functions on LAS
Other
12 stars 2 forks source link

`read_las()` fails due to `.las_get_log_data()` function. #12

Open mschmidty opened 1 year ago

mschmidty commented 1 year ago

I'm working with a V2.0 LAS file. Using las_read produces an error:

 las_test<-read_las(file_url, replace_null=TRUE)                                  
[1] "GoodmanPoint_-All-Logs.las"
 [1] 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36
Warning messages:
1: In data.table::fread(lines, showProgress = FALSE) :
  Detected 3 column names but the data has 24 columns (i.e. invalid file). Added 21 extra default column names at the end.
2: In data.table::fread(lines, showProgress = FALSE) :
  Stopped early on line 26. Expected 24 fields but found 25. Consider fill=TRUE and comment.char=. First discarded non-empty line: <<7024.00    32.1877    49.1371    96.3153    2.43900    -2.200e -04  11.8670    85.7672    6.15800    52.1994    93.3572    2.64798    0.03725   10000.00    0.14848    0.24008    0.61144    0.00000    0.00000    0.00000    0.00000    0.00000    0.00000    1.00000>>

The -2.200e -04 value I believe is the problem. There is a space in between the "e" and the "-" that is causing data.table::fread to add an extra column for this line. I attempted to remove the space using a regex prior to reading it, but there is a line in the .las_get_log_data function that adds the space back in. On line 169 in las_read.R there is lines <- stringr::str_replace_all(lines, "-", " -") which adds a space prior to any negative symbol. Removing this fixes the function for me and the file reads in normally.

I figure this step is here for a reason. But wanted to let you know that with at least some .las log files this breaks read_las().