# NOT RUN {
# This example computes the mean elevation of points above 5 m over an entire
# catalog, after removing all points in lakes into a shapefile.
LASfile <- system.file("extdata", "Megaplot.laz", package="lidR")
shapefile_dir <- system.file("extdata", package = "lidR")
ctg = catalog(LASfile)
tiling_size(ctg) <- 160
lakes = rgdal::readOGR(shapefile_dir, "lake_polygons_UTM17")
my_grid_metrics = function(x, res, spdf)
{
lasclassify(x, spdf, "inpoly")
x = lasfilter(x, !inpoly)
grid_metrics(x, mean(Z), res)
}
mean = grid_catalog(ctg, my_grid_metrics, 20,
select = "xyz", filter = "-drop_z_below 5",
spdf = lakes)
# }
Run the code above in your browser using DataLab