Geographic Information Systems Asked on May 1, 2021
I’m new to R and to lidR.
I have LAS files that are already ground classified and I’m attempting to use the method below to classify the vegetation and then write a new LAS file retaining the ground and vegetation classifications. The resulting LAS files end up with every point classified as vegetation.
What am I doing wrong?
Here’s my script:
library(lidR)
las <- readLAS("D:/tree-segmentation/test.las", select = "xyzc", filter = "-drop_z_below 0")
las <- segment_trees(las, li2012(R = 3, speed_up = 5))
plot(las, color = "treeID")
vegetation_class = function(Z)
{
mz = max(Z)
if (mz < 10)
return(LASLOWVEGETATION)
else if (mz >= 10 & mz < 22)
return(LASMEDIUMVEGETATION)
else
return(LASHIGHVEGETATION)
}
las@data[!is.na(treeID), Classification := vegetation_class(Z), by = treeID]
plot(las, color = "Classification")
writeLAS(las, "D:/tree-segmentation/test-veg-classified.las", index = FALSE)
segment_tree()
segments from top to bottom no matter the class of the points. This means that ground points have also a treeID
las@data[!is.na(treeID) & Classification != LASGROUND, Classification := vegetation_class(Z), by = treeID]
Answered by JRR on May 1, 2021
Get help from others!
Recent Questions
Recent Answers
© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP