Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

writeLAS and Header Size #61

Closed
karnayogendra opened this issue May 8, 2017 · 7 comments
Closed

writeLAS and Header Size #61

karnayogendra opened this issue May 8, 2017 · 7 comments
Assignees
Labels
Bug A bug in the package

Comments

@karnayogendra
Copy link

Hi,

I have a tile with a 'header size of 235. However when i save this file using writeLAS it is changing the 'Header size to 227. This is creating errors when i re-import the tile:

WARNING: for LAS 1.� header_size should at least be 235 but it is only 227
WARNING: for LAS 1.� header_size should at least be 235 but it is only 227
WARNING: for LAS 1.� header_size should at least be 235 but it is only 227
WARNING: for LAS 1.� header_size should at least be 235 but it is only 227
Warning messages:
1: Invalid file: header states the file contains 11221946 1st returns but 16096836 were found. Header has been updated.
2: Invalid file: header states the file contains 8310139 2nd returns but 9559154 were found. Header has been updated.
3: Invalid file: header states the file contains 4354005 3rd returns but 0 were found. Header has been updated.
4: Invalid file: header states the file contains 1439017 4th returns but 0 were found. Header has been updated.
5: Invalid file: header states the file contains 288440 5th returns but 0 were found. Header has been updated.

I have tried to re-import the file using LASTools, so I suspect the header size is being changed during writeLAS. The result is a corrupted file when saving.

The tile causing the issue is new (Version 1.3). We spoke with Martin Isenburg and he recommended the writeLAS needs to be set at Version 1.2 to avoid this error. We are wondering what the current setup is for writeLAS in the lidR package.

Thanks.

@Jean-Romain
Copy link
Collaborator

Jean-Romain commented May 8, 2017

Hi,

Thank you for reporting the bug. Please could you attach an example file and an example code. I must make some test myself to find the problem.

Regards

@Jean-Romain Jean-Romain self-assigned this May 8, 2017
@Jean-Romain Jean-Romain added the Bug A bug in the package label May 8, 2017
@Jean-Romain Jean-Romain added this to the v1.2.1 milestone May 8, 2017
@Jean-Romain Jean-Romain added this to Todo in Roadmap v1.2.1 May 8, 2017
@Jean-Romain Jean-Romain moved this from Todo to Aborded in Roadmap v1.2.1 May 24, 2017
@Jean-Romain Jean-Romain added this to Projects in Roadmap v1.3.0 May 24, 2017
@karnayogendra
Copy link
Author

karnayogendra commented Jun 2, 2017 via email

@Jean-Romain
Copy link
Collaborator

No problem. A little subset of it should be enough. What I need is only a toy example with the proper metadata to reproduce the problem not the whole dataset.

@karnayogendra
Copy link
Author

Hi Jean,

Here is the subset of one tile that I have clipped for 100*100 m. After that I exported the clipped tile as another las file, which is written as test_write_las.las but while I try to read it shows the message as of first email.
The code I have used are:
Infile <- "F:/PilotTest_Confirmation/data/LasFiles/e387n5847_centralhighlands_2016jan09_mpts-c2_v20cm_ahd-mga55.las"
Infile
ReadLas <- readLAS(Infile)
clip1 <- lasclipRectangle(ReadLas, 387593, 5847324, 387693, 5847424, inside = T)
clip1
writeLAS(clip1, file = "F:/PilotTest_Confirmation/data/LasFiles/test_write_las.las")
Rtest <- readLAS("F:/PilotTest_Confirmation/data/LasFiles/test_write_las.las")

The sample subset of clipped file is attached herewith.

testfile.zip

@Jean-Romain
Copy link
Collaborator

Well, I'm really grateful for your help but you provided me the output files (the corrupted one). What I need is the original file to reproduce the bug. Indeed I perfectly understand the problem but I don't have a las file in version 1.3 to reproduce the problem. And I'm not able to understand it only reading the code. Indeed the header_size is not expected to be modified. If you don't want to send me an original fileI understanf but please copy the output of lasinfo (from LAStools or liblas) or simply print(ReadLas@header))

Regards

@karnayogendra
Copy link
Author

karnayogendra commented Jun 7, 2017

Hi Jean,

Please find the link for data download.
https://www.dropbox.com/sh/mwp56ewohkrrdd5/AABHDD-Xq45imilaEmCWd-fRa?dl=0

If it will not work, please let me know.

Thanks and Regards,
Yogendra

@Jean-Romain
Copy link
Collaborator

Jean-Romain commented Jun 7, 2017

It was easy to find the bug with the good data. It was not a bug with lidR but with rlas. Please update rlas.

Notice that the way I write las file is not perfect. There are some informations lost from the original file.

  • The variable length records which usually contains information about the projection. I didn't figure out how to write it yet.
  • The extra data. To make it simple the data provider can write anything he want between the header and the data (points). To do so the header should explicitly contains the positioning of the point in the file. I don't know how to read these extra info and how to write them. So the output file skip these informations.

But everything else sounds good.

@Jean-Romain Jean-Romain removed this from Projects in Roadmap v1.3.0 Jun 7, 2017
@Jean-Romain Jean-Romain moved this from Aborded to Done in Roadmap v1.2.1 Jun 7, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug A bug in the package
Projects
No open projects
Development

No branches or pull requests

2 participants