With a loaded point-cloud (LAS
) you can use merge_spatial()
. Lets load some data first:
library(lidR)
library(sf)
LASfile <- system.file("extdata", "Megaplot.laz", package="lidR")
shp <- system.file("extdata", "lake_polygons_UTM17.shp", package = "lidR")
las <- readLAS(LASfile)
poly <- st_read(shp, quiet = TRUE)
plot(las@header)
plot(poly, add = TRUE)
We can now use merge_spatial()
to know if points are in or out the polygon(s). Then we can use this information to clip or classify.
las <- merge_spatial(las, poly, "inpoly")
las$Classification[las$inpoly == TRUE] <- LASWATER
las$Classification[las$inpoly == FALSE & las$Classification != LASGROUND] <- LASLOWVEGETATION
plot(las, color = "Classification")
veg = filter_poi(las, inpoly == FALSE)
plot(veg)
However it is not possible (yet) to directly classify the point-cloud from a LAScatalog
. You must build your own tools based on this answer and catalog_apply()
clip_roi()
function?