# NOT RUN {
LASfile <- system.file("extdata", "MixedConifer.laz", package="lidR")
las <- readLAS(LASfile, select = "xyz", filter = "-inside 481250 3812980 481300 3813050")
# point-cloud-based
# =================
# 5x5 m fixed window size
ttops <- find_trees(las, lmf(5))
#x <- plot(las)
#add_treetops3d(x, ttops)
# variable windows size
f <- function(x) { x * 0.07 + 3}
ttops <- find_trees(las, lmf(f))
#x <- plot(las)
#add_treetops3d(x, ttops)
# raster-based
# ============
chm <- grid_canopy(las, res = 1, p2r(0.15))
ttops <- find_trees(chm, lmf(5))
plot(chm, col = height.colors(30))
plot(ttops, add = TRUE)
# variable window size
f <- function(x) { x * 0.07 + 3 }
ttops <- find_trees(chm, lmf(f))
plot(chm, col = height.colors(30))
plot(ttops, add = TRUE)
# }
Run the code above in your browser using DataLab