Quantcast
Channel: User JRR - Stack Overflow
Viewing all articles
Browse latest Browse all 43

Answer by JRR for Lack of precision when using the lidr package's segment_trees function

$
0
0

The mistake you made was to compute the local maxima from the point cloud and then use these maxima as seed on a raster that was modified with a focal function. The local maxima of the raster no longer match the maxima found in the point cloud because the smoothing moved the maxima in the raster. Then the segmentation was messed up.

Compute the maxima from your raster.

library(lidR)library(terra)test.placette <- lidR::readLAS('~/placette2.las')las.norm <- lidR::normalize_height(test.placette, algorithm = tin(),na.rm =T, res= 0.3)las.norm <- filter_poi(las.norm, Z >= 0, Z<50)chm <- rasterize_canopy(las.norm, res = 0.5, p2r(0.2, na.fill=tin())) w <- matrix(1,3,3)chm.smoothed <- raster::focal(chm, w, fun = mean, na.rm =T)plot(chm.smoothed, col = height.colors(25))ttops <- locate_trees(chm.smoothed, lmf(ws = 3))ttops <- ttops[which(ttops$Z >= 4),]plot(ttops, add = T, pch = 19)algo <- dalponte2016(chm.smoothed,ttops, th_tree = 1)seg = algo()plot(seg, col = pastel.colors(50))plot(ttops, add = T, pch = 19)las.segmented <- segment_trees(las.norm, algo) plot(las.segmented, bg = "white", size = 8, color = "treeID") crowns <- crown_metrics(las.segmented, func = .stdtreemetrics, geom = "convex")plot(crowns$geometry, col =height.colors(25), main ="Crown with Tree tops")plot(sf::st_geometry(ttops), add = TRUE, pch = 3)

Viewing all articles
Browse latest Browse all 43

Latest Images

Trending Articles





Latest Images