I am trying to output the result of li2012 tree segmentation but can't seem to write the new attribute in the original las file or into a new file. This is the code I have:

las = readLAS("path/to/input.las", select = "c", filter = "-drop_z_below 0")
las_1 <- segment_trees(las, li2012(dt1 = 1.4))
writeLAS(las_1, "path/to/output.las")

the segment trees line took 2 days to run but I can't view it or use it. and my writeLAS code ran through the weekend with no results and no error. Am I trying to create an output correctly. better yet, can I just write it into a new attribute in my original file?

1 Answer 1


It is difficult to say where you made an error without a reproducible example. Below a reprex, it works just as expected.

LASfile <- system.file("extdata", "MixedConifer.laz", package = "lidR")
las_1 <- readLAS(LASfile)
las_1 <- segment_trees(las_1, li2012(dt1 = 1.4))
f <- tempfile(fileext = ".las")
writeLAS(las_1, f)
las_2 = readLAS(f)
#> [1]  79  79  79  79  79 124

That being said li2012 is known to me slow. This is inherent to the method described in the paper

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.