lidR – What is the filter_poi() Equivalent to readLAS(…, “-keep_last”)?

filterlaslidrr

With the excellent lidR package we can filter at C++ level when using readLAS(), e.g. with the following syntax

lidar = readLAS(LASfile, filter="-keep_first")

or when the pointcloud is already loaded at the R level, where above filter would translate to:

lidar_first = filter_poi(lidar, ReturnNumber == 1L)

Now I am wondering: What is the equivalent to keep_last?

It would be nice having a full list of attributes I could filter on. The doc elaborates on (LAStools/C++) options at the readLAS function (respectively one can list these with readLAS(filter = "-help")), but I haven't found a list of the R equivalents.

Best Answer

With a little trial and error, I found that this works:

lidar_first = filter_poi(lidar, ReturnNumber == NumberOfReturns)

The list of potential select attributes for readLAS in the documentation gave me the hint that there might be a variable NumberOfReturns available (there it is called r - number of returns). However I haven't found any explicit hints on that anywhere.

A comprehensive list of filter options for readLAS() / opt_filter() can be found by running readLAS(filter = "-help")

Related Question