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

Shift of Z values in writeLAS output #4

Closed floriandeboissieu closed 7 years ago

floriandeboissieu commented 7 years ago

Hi Jean-Romain, I noticed a 0.01 shift of certain Z values when writing to las/laz, there seem to be a bug there. It seems to be related with some particular Z values, see code below. Here is how I could reproduce the bug:

LASfile <- system.file("extdata", "Megaplot.laz", package="lidR") lidar = readLAS(LASfile) writeLAS(lidar,"~/Megaplot.cpy.laz") 365868 bytes written Column pulseID skipped. It does not meet las specifications. lidar1=readLAS("~/Megaplot.cpy.laz") any(lidar$Z-lidar1$Z>0) [1] TRUE (lidar$Z-lidar1$Z)[lidar$Z-lidar1$Z>0][1:10] [1] 0.01 0.01 0.01 0.01 0.01 0.01 0.01 0.01 0.01 0.01

writeLAS(lidar1,"~/Megaplot.cpy.cpy.laz") 365868 bytes written Column pulseID skipped. It does not meet las specifications. lidar2=readLAS("~/Megaplot.cpy.cpy.laz") any(lidar2$Z-lidar1$Z>0) [1] FALSE

floriandeboissieu commented 7 years ago

Easier to copy paste like this maybe

LASfile <- system.file("extdata", "Megaplot.laz", package="lidR")
lidar = readLAS(LASfile)
writeLAS(lidar,"~/Megaplot.cpy.laz")
lidar1=readLAS("~/Megaplot.cpy.laz")
any(lidar$Z-lidar1$Z>0)
(lidar$Z-lidar1$Z)[lidar$Z-lidar1$Z>0][1:10]
writeLAS(lidar1,"~/Megaplot.cpy.cpy.laz")
lidar2=readLAS("~/Megaplot.cpy.cpy.laz")
any(lidar2$Z-lidar1$Z>0)
Jean-Romain commented 7 years ago

Try that one. It's fine on my computer (devel branch). It was a problem of computer precision