My dataset is about 8.3 GB after loaded into R environment by using lidR package. Some points which have return number greater than number of returns need to be removed.
With a small dataset, I could just use:
l <- lasfilter(las, ReturnNumber <= NumberOfReturns)
which is not possible with my PC.
What is the right way to filter (to use 'lasfilter' on) huge LiDAR data? I am not sure which one to chose from the list of filter expression for argument 'filter' in the 'readLAS' function. I modified a sample dataset from lidR package so it has points that return number are greater than their number of returns:
library(lidR) LASfile <- system.file("extdata", "Megaplot.laz", package="lidR") las = readLAS(LASfile) # make rn > nr las@data$ReturnNumber <- 3L las@data$ReturnNumber <- 3L writeLAS(las, "/TEMP/rnGTnr.laz") # using "-keep_last", guessing from its source code (and it's wrong) las2 <- readLAS("/TEMP/rnGTnr.laz", filter = "-keep_last") # > Warning message: # > Invalid data: 2 points with a 'return number' greater than the 'number of returns'.
So, the problem persists.
Can it be done using LASCatalog object (by dividing the data into chunks)? I don't know how to filter using LASCatalog object. There is a filter option for LASCatalog, and again I don't know which one is appropriate for my case.