I am just wondering whether lasfilter()
is able to filter the las data with more than two criteria such as z value between 5 and 10 m and Number of point records greater than 1. I have tried the following code but it didn't work. I don't know how to filter the datasets with multiple criteria. There are 1173 files in my folder but when I used the following code it could only write 67 files because after 67th file there is another file which doesn't have point fitting with this criteria. So I want to write all those files which do meet the above criteria.
plotlist16 <- list.files(path = "./data/LidarData/2016_random_plot/AllTogether/normalized", pattern = ".las", full.names = T, recursive = FALSE)
for (i in 1:length(plotlist16))
{
Rplot <- readLAS(plotlist16[i])
ht_1.3_5m <- lasfilter(Rplot, Z>=1.3 & Z<5) # with this could only write 67 files
ht_1.3_5m <- lasfilter(Rplot, Z>=1.3, Z<5, Rplot@header@PHB$Number of point records>=1) # so want to filter with third criteria which has at least one point in this height range
file_name <- gsub('.*/','',plotlist16[i])
file_name <- gsub('.las','',file_name)
file_name <- print(file_name)
outname <- paste0('./data/LidarData/2016_random_plot/AllTogether/stratawise/strata_1.3_5m/', file_name, "_ht_1.3_5m.las")
writeLAS(ht_1.3_5m, outname)
}