I have an atrribute of an lidar data which i get using the filter_poi function how do i get the length of this attribute.

Here is my code

las <-readLAS("C:\\lid\\Test.las")
las <- filter_poi(las, treeID == i)

I want to run a loop on this treeID attribute but i dont the final length of the attribute in order to stop the loop how do i get the length of this attribute in R.

1 Answer 1


You can use regular R idioms

ids = unique(las$treeID)
  • I added ids <- length(ids) after the code above which gives me the total length of the attribute
    – Purple_Ad
    Nov 29, 2022 at 14:51
  • No it only gives you the number of unique id
    – JRR
    Nov 29, 2022 at 15:55
  • Yes the code you posted only gives me the number of unique id. But i commented that your code plus the length function gives me what i wanted.
    – Purple_Ad
    Nov 30, 2022 at 7:15

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.