0

I am trying segementation of trees using lidr. I need to count how many points are segemented in each tree. i have a las variable which has an attribute treeID. Using filterpoi i can get individual tree id and see how many points are there. i want to extract the points and create a list for all tree id. My idea is to loop through the treeID and get points for each id. But i cannot seem to extract the points individually . When i print the variable las i get some information i only need the "points". How can i extract this

las <-segment_trees(las, algo) # segment point cloud


las <- filter_poi(las, treeID == 1)

> las
class        : LAS (v1.4 format 6)
memory       : 86.8 Kb 
extent       : 368194, 368203.5, 5807536, 5807544 (xmin, xmax, ymin, ymax)
coord. ref.  : WGS 84 / UTM zone 33N 
area         : 67.9 m²
points       : 1.1 thousand points
density      : 16.11 points/m²
density      : 9.96 pulses/m²
Purple_Ad
  • 65
  • 6
  • Maybe `las$points`? If not, you can use `View(las)` and try to identify the name of the element that storage the points info, and then use that name to access the info. – Ricardo Semião e Castro Nov 25 '22 at 11:37
  • las$points gives me null. I found if i print the header Num. of points record shows the data which i want but it also gives me null when i use the code you mentioned – Purple_Ad Nov 25 '22 at 11:57

1 Answers1

0

You can aggregate the data.table

las@data[, length(X), by = treeID]
JRR
  • 3,024
  • 2
  • 13
  • 37