首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >运行一个while循环以获取r中的激光雷达数据中的点数。

运行一个while循环以获取r中的激光雷达数据中的点数。
EN

Stack Overflow用户
提问于 2022-11-25 13:04:46
回答 1查看 23关注 0票数 0

我使用lidR包在r中分割了树。分段的树有一个与它们相关联的id。我想知道每棵树有多少分。我使用tree循环来获取每棵树的点,但我只从第一个treeId获得点。

代码语言:javascript
复制
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
EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2022-11-25 15:31:32

您正在用las覆盖while循环中的原始las <- filter_poi(las, treeID == i)。如果你把这个分配给别的什么东西,它会起作用吗?例如:

代码语言:javascript
复制
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
}
pointlist
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/74573264

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档