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

Crown segmentation algorithms do not work when run outside `segment_trees()` function #348

Closed ptompalski closed 4 years ago

ptompalski commented 4 years ago

When performing crown segmentation with either of the raster-based algorithms (e.g. silva2016, or dalponte2016), a following error message is returned:

Error in if (!received_context %in% expected_contexts) stop(glue::glue("The '{name}' algorithm has not been called in the correct context."), : argument is of length zero

In the code below everything runs ok except the last line:

library(lidR)
LASfile <- system.file("extdata", "MixedConifer.laz", package="lidR")
las <- readLAS(LASfile, select = "xyz", filter = "-drop_z_below 0")

chm = grid_canopy(las, 1, p2r())
ttops = find_trees(chm, lmf(3))
crowns = dalponte2016(chm, ttops)()
Jean-Romain commented 4 years ago

It works for me. I guess you are using a development version that has been updated at a very bad moment when I introduced this bug inadvertently. But I think I fixed that recently before to release 3.0.0. Try to update first from master that now contains the released version 3.0.0

ptompalski commented 4 years ago

yup, works fine after updating.