0

I have las files along coastal areas which include multiple flights. Usually I use both water and ground when normalizing but this data has 2 things to overcome. The first has ground at a lower level than water due to tides. The second is a problem because one flight classified vegetation as water. To help solve this (a quick attempt at ground classification didn't quite work), I want to extract water and ground, and then use point_metrics() to get the minimum value within a small neighbourhood. The idea is to use this minimum value as ground during normalization. How can I export the results of point_metrics() data table to a raster or las file (it has pointId & V1)?

[![profile of las with classification][1]][1]

library(raster)
setwd('D:/test/las')
las <- readLAS('579_4998_201801.las', filter = "-keep_class 2 9")
lasmin <- point_metrics(las, func = ~min(Z), k = 2, r = 1)


  [1]: https://i.sstatic.net/7bsmC.png
1
  • I messed up this question and edited it after posting (sorry about that). I tried to convert the output of lasmin to a LAS file las2 = LAS(lasmin, las@header) but the xy coordinates are gone. In the end, I think I should reclassify using classify_ground. I will try and edit the code above but hope I don't confuse things more.
    – Ray J
    Commented May 18, 2022 at 17:29

1 Answer 1

1

There are plenty of options depending on what you really want to do.

You can keep only the points with min Z that way

library(lidR)
f = system.file("extdata", "Topography.laz", package="lidR")
las = readLAS(f, filter = "-keep_class 2 9")
min = point_metrics(las, func = ~list(minZ = min(Z)), k = 2, r = 1)
boo = min$minZ == las$Z                    
gnd = las[boo]

If you want to get XYZ there is an option for that:

min = point_metrics(las, func = ~list(minZ = min(Z)), k = 2, r = 1, xyz = TRUE)

If you want to reclassify the points based on the output of point_metrics() this is also doable but a little bit harder.

1
  • This works well, thanks. In the end I will use classify_ground() because it is safer. But point_metrics with x,y will be useful later on.
    – Ray J
    Commented May 18, 2022 at 17:41

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.