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

write.las writes a deeply corrupted file #25

Open
jstrunk001 opened this issue Dec 5, 2018 · 4 comments
Open

write.las writes a deeply corrupted file #25

jstrunk001 opened this issue Dec 5, 2018 · 4 comments
Assignees
Labels
Bug A bug in the package

Comments

@jstrunk001
Copy link

Hello, I have a specific set of laz files that result in strange behavior when read / write with lidR

library(lidR)
las1 = readLAS("SubArea_012_011.8_6.las")
las1
f = tempfile(fileext = ".las")
writeLAS(las1, f)
las2 = readLAS(f)
las2

SubArea_012_011.8_6.las.zip

@Jean-Romain Jean-Romain changed the title writeLAS writeLAS writes a deeply corrupted file Dec 5, 2018
@Jean-Romain
Copy link
Collaborator

Jean-Romain commented Dec 5, 2018

The error is reproducible without lidR. Moving the issue to rlas

data1 = read.las("~/Téléchargements/SubArea_012_011.8_6.las")
header1 = read.lasheader("~/Téléchargements/SubArea_012_011.8_6.las")

f = tempfile(fileext = ".las")

write.las(f, header1, data1)

data2 = read.las(f)
#> ERROR: 'end-of-file' after 6359 of 6365 points
#> Warning: there are 19 points flagged 'withheld'.
#> Warning: there are 3658 points flagged 'synthetic'.

header2 = read.lasheader(f)

@Jean-Romain Jean-Romain transferred this issue from r-lidar/lidR Dec 5, 2018
@Jean-Romain Jean-Romain changed the title writeLAS writes a deeply corrupted file write.las writes a deeply corrupted file Dec 5, 2018
@Jean-Romain Jean-Romain self-assigned this Dec 5, 2018
@Jean-Romain Jean-Romain added the Bug A bug in the package label Dec 5, 2018
@Jean-Romain
Copy link
Collaborator

Well, I found the issue. But in the meantime I don't know how to fix it and I'm not even sure if I should fix it. Basically the header states to add an offset in the binary file but this offset is not respected. I'm not going through details. The following fixes your issues waiting for a better internal fix.

library(lidR)

las = readLAS("SubArea_012_011.8_6.las")
las@header@PHB$`Header Size` = 235

f = tempfile(fileext = ".las")
writeLAS(las, f)

I'm wondering if @floriandeboissieu have a better understanding of the header size management in LASlib

@jstrunk001
Copy link
Author

jstrunk001 commented Dec 5, 2018 via email

@floriandeboissieu
Copy link
Contributor

Sorry for the late answer, I don't have much time this end of year.
I'll dig into it as soon as I can.

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
None yet
Development

No branches or pull requests

3 participants