I'm applying lasnormalize
with catalog_apply
in lidR with opt_chunk_buffer
set to 20 metres. I do not remove the buffer explicitly and the normalized las files, which are returned, include the hits from the buffer (i.e. my resulting las files now extend 20 metres beyond their original extent). I had interpreted the lidR manual that buffer removal is automatic - but maybe I need to remove the buffer with code? Many thanks for clarifying.
library(lidR)
ctg <- readLAScatalog("J:/2019/LAS")
normF = function(chunk)
{
las = readLAS(chunk)
if (is.empty(las)) return(NULL)
# skip las files that do not have ground hits
ground <- lasfilter(las, Classification == 2)
if (is.empty(ground))
return(NULL)
lasNorm <- lasnormalize(las, algorithm = knnidw(k = 10, p = 2), na.rm = FALSE, use_class = c(2L, 9L))
#-----------------------------------------------------------------
# This is the line needed, as identified in the answer below...
lasNorm <- lasfilter (lasNorm, buffer == 0)
#-----------------------------------------------------------------
return(lasNorm)
}
opt_filter(ctg) <- "-drop_withheld -drop_overlap -drop_z_below 0"
opt_chunk_buffer(ctg) <- 20
opt_output_files(ctg) <- ("J:/2019/LAS_normalized/{ORIGINALFILENAME}_norm")
mylasCatalogueNorm <- catalog_apply(ctg, normF)