3

Trying to further classify a las catalog that already has buildings, bridges, noise and ground classified. I want to break the unassigned points into vegetation classes by height but can't get it to work. some previous questions have used tree segmentation, I haven't run individual tree segmentation and I don't think I need to?


vegetation_class = function(Z)
{
  mz = max(Z)
  if (mz < 6)
    return(LASLOWVEGETATION)
  else if (mz >= 6 & mz <12)
    return(LASMEDIUMVEGETATION)
  else if (mz >=12 & mz <60)
    return(LASHIGHVEGETATION)
  else
    return(LASNOISE)
}

veg_ctg@data[Classification = vegetation_Class(Z)]

writeLAS(veg_ctg, "D:mypath/new1.las", index = FALSE)```


Any help is greatly appreciated.

1 Answer 1

3

This is what I'd do

library(lidR)

vegetation_class = function(mz)
{
  class = integer(length(mz))
  class[] = LASNOISE
  class[mz < 10] = LASLOWVEGETATION
  class[mz >= 10 & mz <20] = LASMEDIUMVEGETATION
  class[mz >=20 & mz <60] = LASHIGHVEGETATION
  return(class)
}

LASfile <- system.file("extdata", "Megaplot.laz", package="lidR")
las = readLAS(LASfile)

chm = rasterize_canopy(las, 2)
las = merge_spatial(las, chm, "chm")

las@data[Classification == LASUNCLASSIFIED, Classification := vegetation_class(chm)]

plot(las, color = "Classification")
plot(filter_poi(las, Classification == LASMEDIUMVEGETATION))

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.