This function is made to be used in segment_trees . It implements an algorithm for tree segmentation based on a watershed. It is based on the bioconductor package EBIimage. You need to install this package to run this method (see its github page). Internally, the function EBImage::watershed is called.
watershed(chm, th_tree =2, tol =1, ext =1)
Arguments
chm: RasterLayer, SpatRaster or stars. Canopy height model. Can be computed with rasterize_canopy or read from an external file.
th_tree: numeric. Threshold below which a pixel cannot be a tree. Default is 2.
tol: numeric. Tolerance see ?EBImage::watershed.
ext: numeric. see ?EBImage::watershed.
Details
Because this algorithm works on a CHM only there is no actual need for a point cloud. Sometimes the user does not even have the point cloud that generated the CHM. lidR is a point cloud-oriented library, which is why this algorithm must be used in segment_trees to merge the result into the point cloud. However, the user can use this as a stand-alone function like this: