Skip to content

Generate CHM or DSM from LiDAR Data

Builds a height surface from the point cloud with lidR::rasterize_canopy. The tool decides what to produce by calling detect_normalized, which reads the ground points of the first LAS/LAZ file in the folder: those in a 100 m square at its centre, through its .lax spatial index, or every 100th ground point of the file when the square has fewer than 100:

  • If the mean |Z| of the ground points (class 2) is below 1, the data counts as height-normalized and the tool produces a CHM.
  • Otherwise, including when there are no ground points, the tool produces a DSM.
Parameter Type Required Description
in_las_folder directory Yes Folder containing the input LAS/LAZ tiles.
out_folder directory (output) Yes Folder for the output rasters.
style tin | pitfree Yes Surface algorithm. The default is tin. An invalid value falls back to tin.
tiling auto | by_file | tiling No How the data is split into tiles (see Tiling). The default is auto.
skip_existing bool No Set to True to resume a run that stopped: tiles whose outputs are complete are skipped (see Resuming a run). The default is False.
processes int No Requested number of parallel workers.
style lidR algorithm Tile output Merged output
tin dsmtin(max_edge = 3 × cell_size) <tile>_TIN_CHM.tif / <tile>_TIN_DSM.tif Merged_TIN_CHM.tif / Merged_TIN_DSM.tif
pitfree pitfree(thresholds = c(0, 3, 5, 10, 15, 20), max_edge = c(0, 3 × cell_size), subcircle = cell_size). Overlap points are also dropped. <tile>_PitF_CHM.tif / <tile>_PitF_DSM.tif Merged_PitF_CHM.tif / Merged_PitF_DSM.tif
from beratools.modules.pc2products.rpy_CHM_DSM_by import rpy_chm_dsm

# DSM from the original tiles
rpy_chm_dsm(in_las_folder="tests/data/LiDAR",
            out_folder="tests/data/LiDAR/Raster_Output",
            style="pitfree")

# CHM from the output of Normalize LiDAR Data
rpy_chm_dsm(in_las_folder="tests/data/LiDAR/Normalized_PC",
            out_folder="tests/data/LiDAR/Raster_Output",
            style="tin")

Command line

bt chm_dsm   # show the parameters
bt chm_dsm --in_las_folder <las_dir> --out_folder <out_dir> --style pitfree