处理我几个月前用旧版本lidR编写的脚本会导致当前版本出现错误。函数名称从lidR::tree_hulls更改为lidR::delineate_crowns
它适用于旧版本,但不适用于新版本。
示例数据: https://github.com/anayana/so_sampla_data/blob/main/so_sample_las.laz (可能有更好的共享数据的方法,欢迎使用提示)
示例代码:
so_sample_las <- readLAS("so_sample_las.laz")
tree.hulls <- lidR::delineate_crowns(clean_las, type="concave", attribute="treeID") 错误消息
Error in (function (cond) :
error in evaluating the argument 'x' in selecting a method for function 'addAttrToGeom': Evaluation error:
IllegalArgumentException: Invalid number of points in LinearRing found 3 - must be 0 or >= 4.我尝试了什么:
删除由少于4个条目表示的treeID的所有点
创建不使用表示不足的树of点的LAS
so_sample_las_dat <- so_sample_las@data
clean_dat <- las.so_sample_las_dat [so_sample_las_dat $treeID %in% names(which(table(so_sample_las_dat $treeID) > 4)), ]
clean_las <- so_sample_las
clean_las@data <- clean_dat
clean_tree.hulls <- lidR::delineate_crowns(clean_las, type="concave", attribute="treeID")错误消息
Error in (function (cond) :
error in evaluating the argument 'x' in selecting a method for function 'addAttrToGeom': Evaluation error:
IllegalArgumentException: Invalid number of points in LinearRing found
3 - must be 0 or >= 4.出现了同样的错误消息。也许我不明白错误信息,或者犯了另一个错误。任何提示都欢迎!
发布于 2022-05-25 15:00:30
我用delineate_crown() (不推荐)和crown_metrics()进行了测试。两样都有用。delineate_crown()生成警告,但可以忽略它们。
library(lidR)
so_sample_las <- readLAS("so_sample_las.laz")
tree.hulls.1 <- delineate_crowns(so_sample_las, type="concave", attribute="treeID")
tree.hulls.2 <- crown_metrics(so_sample_las, func = NULL, geom = "concave", attribute = "treeID")更新您的包,如果您仍然遇到麻烦,报告一个错误。
https://stackoverflow.com/questions/72378483
复制相似问题