1

I have a set of 10 LiDAR files that I'm attempting to retile and eventually use to create a Canopy Height model. I'm able to import them as a catalog, however when I go to retile my catalog, I get the following error:

Error: File not found
In addition: Warning message:
In normalizePath(path.expand(path), winslash, mustWork) :
  path[1]="NA": The system cannot find the file specified

Additionally, the progress figure looks like this (indicating there were not data points found in each file):

enter image description here

To investigate, I imported a single LiDAR file, and was successfully able to plot the point cloud. Proving that there definitely ARE data in the file. However, upon importing the file, I got the following warning:

Warning messages:
1: Invalid file: header states the file contains 0 points but 3408961 were found.
2: Invalid file: the header states the file contains 0 1st returns but 3322882 were found.
3: Invalid file: the header states the file contains 0 2nd returns but 81189 were found.
4: Invalid file: the header states the file contains 0 3rd returns but 4852 were found.
5: Invalid file: the header states the file contains 0 4th returns but 58 were found.

And when looking at the header, it tells me the number of point records is 0. However, using summary(), on the file, I'm told I have "3408961 points, NA pulses."

This is all very perplexing to me. Does anyone know of any possible solutions?

  • 1
    It sounds like the files are bad or mistagged, the ASPRS LAS 1.4 has moved the counters to later in the header and the old counters must be set to 0. Do you have LasTools? if so a quick LASInfo would explain a lot or even better LASInfo <your_las_file> -repair would fix to the ASPRS standard. – Michael Stimson Dec 21 '18 at 0:26
  • @MichaelStimson I've just attempted to use the LASinfo executable to correct one of my file's headers, but the resulting file in my output directory was a text file with the header info, rather than a las file. Within the executable, I selected 1 las file, and clicked the "repair counters" box. I'm almost certainly using this tool wrong (I have very very little experience in LAStools). If it's not too much trouble, would you mind providing a little more detail on how to use LASinfo to correct my headers? – Pairsa Belamaric Dec 29 '18 at 5:50
  • @AndreSilva I did not run any code. I used the LASinfo executable (as mentioned in my comment), so it was a user interface. Is there a way for me to use LAStools in R? This is the only coding language I know. Where would I use the "LASInfo <your_las_file> -repair" solution? When I open the executable, a command prompt opens, but I'm not able to type into it. – Pairsa Belamaric Dec 31 '18 at 23:22
  • Great, thanks! I'll keep trying and open up a new question if I keep running into trouble. – Pairsa Belamaric Jan 2 at 1:07
2

Your files are invalid with respect of the formal las specification. The header of a file should contains information including the bounding box of the file, the number of point recorded as well as many other informations. Your file header states that the files contain 0 point but it actually contains 3408961 points. You have a warning for that.

It means that points were read but you should be careful. Your file is incorrect. From my own experience an incorrect file often comes with other issues.

As mentioned by Michael Stimson you can fix it with the free an open source part of LAStools. The lidR package fixed it at the R level but did not modify the original files.

That is for the warnings. For the error when retiling you did not provide your code but I'm pretty sure it is related.


That being said my answer is perfectly correct for LAS file formats 1.0 to 1.3. For LAS format 1.4 this error may also be related to a partial support of the format. The format 1.4 is not entirely supported in lidR. For example header of LAS 1.4 contains (among other) an field extended number of points records and this attributes is not read in lidR.

In short at the time being (Dec 31 2018), LAS format 1.4 is not fully supported in lidR. Be careful on the content read in R. It may or may not be related to the format I must investigate and read carefully the las specification. I will enable a better support of LAS 1.4 in 2019.

  • Thanks for your feedback! Ok, so, in your other comment you say "Read -> Write should be enough. lidR already fixed internally your issue at read time with rlas." I just want to make sure I understand what you're saying here. Are you saying that if I simply import a lidar file using lidR, then write it (without the creation of a new header), that my header should be repaired anyway? And if so, why is LAStools a better option/necessary step? I'm happy to try it, if it will save me a future headache! Just trying to understand why. Also, what tool within the LAStools suite should I be using? – Pairsa Belamaric Dec 28 '18 at 1:25
  • 1
    Your header errors are simple and thus fixed at read time without the need to create a new header. Yes. LAStools is betters because (i) it does not load the data in memory to fix the header (more efficient) (ii) it has a full support of the las specifications and thus won't loose any information at write time. lidR will lose few metadata from the header e.g. some geotiff tags and (iii) if there are other issues they will probably be fixed as well. Which tool? I don't know but according to Michael Stimson's comment lasinfo yourfie.las -repair should make the job. – JRR Dec 28 '18 at 13:59
0

I think I might have found a solution, but I'm worried it's more of a band-aid.

I used the package rlas in the following for loop to create a header from the data in each file, then overwrite the existing (incorrect) headers and save the corrected files in a new folder:

library(rlas)

# create list of all files in folder  
las <- dir(pattern = ".las")  

for(i in 1:length(las)){  
temp <- readLAS(las[i])  
temp@header@PHB <- header_create(temp@data)  
filename = paste0("./Fixed header/", las[i])  
write.las(filename, temp@header@PHB, temp@data)  
}  

Now, when I import these newly saved files, I no longer get the warnings I was getting before. And I'm still able to plot each file. Also, I can now import these files into a catalog and successfully retile them using this code:

library(lidR)

# Import files into a catalog  
westcoast.ctg  = catalog("./West Coast 2016/Use/Projected/Fixed header")  
plot(westcoast.ctg)  

# Make tiles smaller   
catalog_retile(westcoast.ctg, path = "./West Coast 2016/NewTiles", "WestCoast", ext = c("las", "laz"))

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

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