使用lidr包的segment_trees函数时缺乏精度

问题描述 投票:0回答:1

简而言之,我正在尝试计算高度超过 7m 的树木的密度,因此我想估计测试地块中每棵树的树冠。为此,我尝试将每棵超过 7m 的树分段以提供给 Crown_metrics 函数。我尝试了使用segment_trees函数的不同方法,使用不同的算法(dalponte2016、silva2016等),并且我还尝试更改算法中的不同参数。到目前为止,dalponte2016给了我最好的结果,但我仍然不满意,因为有些点没有很好地分割(我尝试截图,我不确定它是否足够清晰)。正如您所看到的(红色圆圈),有些点没有被分割,即使它们显然是树的一部分。 我想到的唯一可能的解释是我的点密度不够(4.6 点/平方米)。 或者我没有正确使用算法。 Points cloud - tree segmentation

这是我的代码(我没有为 dalponte2016 尝试使用不同的参数):

las <- lidR::readLAS('Data/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)

ttops <- locate_trees(las.norm, lmf(ws = 3))
ttops <- ttops[which(ttops$Z >= 7),]

algo <- dalponte2016(chm.smoothed,ttops)
las.segmented <- segment_trees(las.norm, algo) 
plot(las, 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)

Result of the crown detection with tree tops

我期待分割和牙冠有更好的结果。有些点没有正确分割,这会导致我的几棵树的树冠估计错误。

我为具有不同参数的segment_trees函数尝试了不同的算法。 我还尝试估计所有树木的树冠,而不仅仅是 7m 以上的树木。

我希望我的脚本成为一个可重现的示例,但我真的不知道如何使用 .LAS 文件来做到这一点。 此致, 莉亚

rstudio point-clouds lidar lidr
1个回答
0
投票

您犯的错误是从点云计算局部最大值,然后使用这些最大值作为用焦点函数修改的栅格上的种子。栅格的局部最大值不再与点云中找到的最大值匹配,因为平滑移动了栅格中的最大值。然后分割就搞乱了。

计算栅格的最大值。

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)
© www.soinside.com 2019 - 2024. All rights reserved.