r-lidar / lidR

Airborne LiDAR data manipulation and visualisation for forestry application
https://CRAN.R-project.org/package=lidR
GNU General Public License v3.0
596 stars 131 forks source link

Error in if (ninvalid > 0) - lidR::crown_metrics #590

Closed anayana closed 2 years ago

anayana commented 2 years ago

trying to process the folowing code an error occurs:

so_example_las_2 <- readLAS("so_example_las_2.laz")
las.trees.2 <- lidR::segment_trees(so_example_las_2, lidR::li2012(dt1 = 1.5, R = 1, speed_up = 10, hmin=1))
tree.hulls <- lidR::delineate_crowns(las.trees.2,type="concave", attribute="treeID")
#> Error in if (ninvalid > 0) { : missing value where TRUE/FALSE needed
shp <- crown_metrics(las.trees.2,  func = NULL,  geom = "concave", attribute = "treeID")
#> Error in if (ninvalid > 0) { : missing value where TRUE/FALSE needed

data can be found here: https://github.com/anayana/so_sampla_data_2/tree/main

As the code is working for other data, this might be a bug.

Jean-Romain commented 2 years ago

Fixed thanks