2

I'd like to export the LiDAR data according to their classification in a georeferenced raster format. Something that look like that:

enter image description here

Here is the code that I tested to retrieve the classification:

nonveg <- filter_poi(las, Classification != LASHIGHVEGETATION)
veg <- filter_poi(las, Classification == LASHIGHVEGETATION)

x <- plot(nonveg, color = "Classification", bg = "white", size = 3)
plot(veg, add = x)`

1 Answer 1

1

Well, without more details I'd say it is not possible because in a given cell you may have points with different classes e.g. low vegetation + high vegetation + ground. Consequently for a given cell you must make a choice to retain only one class. Here I will assume you want to retain the class that is represented by more numerous points. So you want Mode(Classification)

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

Mode <- function(x) {
  ux <- unique(x)
  return(ux[which.max(tabulate(match(x, ux)))])
}

map = grid_metrics(las, ~Mode(Classification), 1)
plot(map)

Here the output is not very interesting because there are only "ground" and "non classified" in this dataset.

1
  • Thanks, that's a great idea. It allows to highlight the different classes. But As you said it also generates a loss of precision on the final rendering. Commented Jun 21, 2021 at 15:31

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.