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

Fail to clip from LAScatalog with both copc and non-copc laz files #68

Closed jmmonnet closed 3 months ago

jmmonnet commented 3 months ago

I have a LAScatalog with files which are either copc or not copc. I noticed that when using parallelisation, some threads ran forever, so I tried to figure out in which cases and when the process does not end. I ended up with one example. clip_circle succeeds with a LAScatalog with two files (one copc, on not copc) depending on the order in which they appear in the catalog.

Those files do not have the same CRS information in the header although they share the same projection

Catalog files with non-copc first cata <- lidR::catalog(c("test.laz", "LHD_FXX_0726_6357_PTS_O_LAMB93_IGN69.copc.laz")) clip_circle runs ok pc <- lidR::clip_circle(cata, 726000, 6357000, 20)

Catalog files with copc first cata <- lidR::catalog(c( "LHD_FXX_0726_6357_PTS_O_LAMB93_IGN69.copc.laz", "test.laz")) clip_circle does not end on my machine (ubuntu) pc <- lidR::clip_circle(cata, 726000, 6357000, 20)

I have lidR 4.0.4 and rlas 1.7.0 from CRAN. I am a bit confused because in some other examples I tested, unexpected behaviours occured (e. g. with 2 non-copc files plus 2 copc files in a LAScatalog, clip_circle does not succeed when lax files are present for the non-copc files, but clip_circle succeeds when the lax files are removed...)

Jean-Romain commented 3 months ago

I confirm the issue. It seems there are some clashes between the standards.

library(lidR)
setwd("/home/jr/Téléchargements/lidR issues/issue 744")

cata <- lidR::catalog(c("test.laz", "LHD_FXX_0726_6357_PTS_O_LAMB93_IGN69.copc.laz"))

plot(726000, 6357000, xlim = c(726000-10, 726000+200), asp = 1, col = "white")
plot(cata, add = T)
plotrix::draw.circle(726000, 6357000, 20)

pc <- lidR::clip_circle(cata, 726000, 6357000, 20)
pc

cata <- lidR::catalog(c( "LHD_FXX_0726_6357_PTS_O_LAMB93_IGN69.copc.laz", "test.laz"))
pc <- lidR::clip_circle(cata, 726000, 6357000, 20)
pc
Jean-Romain commented 3 months ago

Minimal reproducible example

setwd("/home/jr/Téléchargements/lidR issues/issue 744")
f = c("test.laz", "LHD_FXX_0726_6357_PTS_O_LAMB93_IGN69.copc.laz")
inside = "-inside_circle 726000 6357000 20"
rlas::read.las(f[1], filter = inside) #ok 
rlas::read.las(f[2], filter = inside) #ok
rlas::read.las(f, filter = inside)    #ok
rlas::read.las(rev(f), filter = inside) #fail

Moving the issue to rlas

Jean-Romain commented 3 months ago

Note to myself: case 3 does not work either it reads only test.laz and return 2255 points

Jean-Romain commented 3 months ago

Fixed. It was a bug in LASlib itself. I'll make a PR to LAStools

Jean-Romain commented 2 months ago

By fixing this bug I created a new one. I fixed it. Please try again to ensure that the initial bug is still fixed.

jmmonnet commented 2 months ago

I am sorry I deleted the "test_laz" file so I cannot test again. I tried with two other files and did not encountered the problem.