# NOT RUN {
# Visit http://jean-romain.github.io/lidR/wiki for more examples
# about this function
# 1. build a project
project = catalog("folder")
plot(project)
# 2. load the shapefile you need to filter your points (if needed).
lake = rgdal::readOGR("folder", "shapefile")
# 3 build the function which analyses a tile (a file).
# This function input is only the path of a .las file
# see the following template
analyse_tile = function(LASFile)
{
# Load the data
lidar = readLAS(LASFile)
# Associate geographic data with lidar points (if needed)
lidar %<>% lasclassify(lake, field="lake")
# filter lake
lidar %<>% lasfilter(lake == FALSE)
# compute standard metrics
metrics = grid_metrics(lidar, .stdmetrics)
return(metrics)
}
#### UNIX #####
# This code works only on Unix platforms because it relies on shared memory
# between all processes. See below for a Windows-compatible code.
# 4. Process the project. By default it detects how many cores you have. But you
# can add an optional parameter mc.core = 3.
output = project %>% catalog_apply(analyse_tile)
#### WINDOWS #####
# This code works on both Unix and Windows platforms. But it is more
# memory-intensive and more complex on Windows (here the example is simple enough
# so it does not change many things)
# 4. Process the project. By default it detects how many cores you have. But you can add
# an optional parameter mc.core = 3.
export = c("readLAS", "lasclassify", "grid_metrics", "myMetrics", "lake", "lasfilter", "%<>%")
output = project %>% catalog_apply(analyse_tile, varlist = export, platform = "windows")
# }
Run the code above in your browser using DataLab