我使用lidR包在r中分割了树。分段的树有一个与它们相关联的id。我想知道每棵树有多少分。我使用tree循环来获取每棵树的点,但我只从第一个treeId获得点。
las <-
segment_trees(las, watershed(
chm,
th_tree = 1,
tol = 0.5,
ext = 2
))
pointlist <- list()
i = 1
while (i < 1000) {
las <- filter_poi(las, treeID == i)
x <- header(las)
y <- x@PHB
points <- y$`Number of point records`
pointlist <- append(pointlist, points)
i <- i + 1
}
pointlist发布于 2022-11-25 15:31:32
您正在用las覆盖while循环中的原始las <- filter_poi(las, treeID == i)。如果你把这个分配给别的什么东西,它会起作用吗?例如:
pointlist <- list()
i = 1
while (i < 1000) {
# las_i instead of las
las_i <- filter_poi(las, treeID == i)
x <- header(las_i)
y <- x@PHB
points <- y$`Number of point records`
pointlist <- append(pointlist, points)
i <- i + 1
}
pointlisthttps://stackoverflow.com/questions/74573264
复制相似问题