Filtering above ground LiDAR points using a catalog in lidR?
In your case the filter you are using is a simple one: Classification != 2
. And you don't need the ground points at all. You are better to use a streaming filter and a streamed processing.
ctg <- catalog("/...2015TestGroup")
opt_chunk_size(ctg) <- 0
opt_chunk_buffer(ctg) <- 0
opt_output_files(ctg) <- ".../Outputs/2015nonground/{XLEFT}_{YBOTTOM}_2015"
opt_filter(ctg) <- "-drop_class 2"
new_ctg <- catalog_retile(ctg)
catalog_retile
is a streamed function. It means that not a single point is loaded at the R level. Each point is read, filtered and written immediately without calling any R code and without loading any memory. It is thus way faster than using the R function lasfilter
.
That being said, you are better to use las2las
from LAStools
for this kind of job. It does exactly the same actually but is more efficient and simple than calling more or less equivalent code from R.
lasfilter
will only directly take objects of class LAS
(and not LAScatalog
) as per the package documentation.
One way to go is with catalog_apply
:
This function gives users access to the LAScatalog processing engine. It allows the application of a user-defined routine over an entire catalog.
So, embed lasfilter
within a user-defined function and pass it to the FUN
argument of catalog_apply
. For example, see Filtering (lasfilter on) huge LiDAR dataset