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.

1 Answer 1


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")


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.