Process a LiDAR Point Cloud with Optional Transect Extraction
Source:R/clip_and_process_transect.R
process_point_cloud.Rd
This function provides a complete workflow for processing a LAS/LAZ file. It can perform decimation, interactive or automated transect extraction, height normalization, and tree segmentation. The key feature is its ability to define a transect area once and then clip it from both the original (unnormalized) and the fully processed point cloud.
Usage
process_point_cloud(
las_file,
normalize = TRUE,
perform_treeID = FALSE,
decimation = FALSE,
extract_transect = TRUE,
cs_width = 1,
offset_x = 15,
odir = NULL,
oname = NULL
)
Arguments
- las_file
A character string specifying the path to the LAS/LAZ file.
- normalize
Logical. If TRUE, the point cloud is height-normalized using a TIN-based DTM. Ground classification should be present for best results. Default is TRUE.
- perform_treeID
Logical. If TRUE, performs tree segmentation using
lidR::silva2016
and merges thetreeID
into the point cloud. Default is FALSE.- decimation
Logical. If TRUE, decimates the point cloud to a resolution of one point per 0.5m voxel. Default is FALSE.
- extract_transect
Logical. If TRUE, the user will be prompted to interactively draw the transect on a DTM plot. If FALSE, a transect is automatically created through the center of the point cloud. Default is TRUE.
- cs_width
Numeric. The width of the transect in the same units as the LAS data. Default is 1.
- offset_x
Numeric. If
extract_transect = FALSE
, this value specifies the start point's X-offset from the minimum X coordinate. Default is 15.- odir
Character string. The path to the output directory where processed files will be saved. If NULL, no files are written. Default is NULL.
- oname
Character string. A base name for the output files. If NULL, "output" is used. Default is NULL.
Value
A list containing three LAS objects:
processed_cloud
: The full point cloud after all processing steps.processed_transect
: The transect clipped from the fully processed cloud.unnormalized_transect
: The transect clipped from the cloud before normalization, retaining original Z values but including any initial classifications (hence the_class
suffix when saved).
Examples
if (FALSE) { # \dontrun{
# Get the path to the example LAS file from lidR
las_file_in <- system.file("extdata", "Megaplot.laz", package = "lidR")
results <- process_point_cloud(
las_file = las_file_in,
extract_transect = FALSE, # Run automatically
perform_treeID = TRUE # Skip tree identification
)
# The results are a list of LAS objects. We can plot them.
# Plot the final, processed transect (heights are normalized)
plot(results$processed_transect)
# To run interactively instead, simply use the default:
# results_interactive <- process_point_cloud(las_file = las_file_in)
} # }