About Us Customers

 uniDEM

Tutorials
User Manual Videos

Lesson 4: Automatic Lidar Classification with UniDEM

This tutorial illustrates a method to automatically process lidar data using scripts in uniDEM accurately and consistently.

Scripts can be recorded while interactively editing DEM and lidar data. Scripts are xml which are stored in, and can be inserted into and exported from uniDEM project files. Scripts can be modified to perform automated editing to program deliverables over large areas any interface that can modify xml files.

Three scripts are provided for illustrative purposes, but can be amalgamated and modified programmatically for fully automated processing using any language that can modify xml files and start an executable.

The following topics will be covered:

For more lessons visit Working with Lidar Point Clouds.

The sample data used in this lesson is 3DEP lidar data in two LAZ files in LAS version 1.2 and located in Madison, MS, USA.

Prior to commencing this lesson, please download the sample data:

This lesson will take approximately 10 minutes.

The following video executes the steps in the tutorial.
s

1. Load and upgrade to LAS 1.4

  1. Click uniDEM icon
  2. Select Load LIDAR
  3. Select both LAZ files
  4. Select Upgrade file format to LAS version 1.4
  5. Click Yes to all files into single dataset
  6. Enter Madison for the combined dataset name
  7. Data is displayed in the Table Of Contents (TOC)
upgrade to las v1.4

Help references:

Load LIDAR | Data Management | Table of Contents

2. Create Supporting Raster Data

The CreateRasters script is used to create the raster layers from the Madison lidar dataset. It will be downloaded and imported into the project file for execution.

  1. Download CreateRaster script
  2. Within the Scripting tab click Import
  3. Select the CreateRasters.xml from the download location
  4. If you have a subscription:
    • Click Edit in the Variables panel
    • Click OK to modify $(DATA_PATH)
    • Enter directory path where data can be written (eg. your working path)
  5. Within the Scripting tab click Run
  6. Select CreateRasters and click OK
Observe: Three rasters (minDEM, stdDev, count) are created.
script to create rasters from las

The following lists the uniDEM tools that are executed by the CreateRasters script:
uniDEM Tool Name Script Tool Name Description
Points to DEM POINTS_TO_DEM Create a raster of the lowest elevation stored in the lidar points intersecting with a pixel of the raster being generated.
Set Active DEM ACTIVE Sets the generated DEM (minDEM) to active allowing editing
Select All (Ctrl-A) SELECT_ALL Select all DEM pixels for editing
Kernel→Inverse Distance Weighted FILL_IDW Fill small areas of missing data with an Inverse Distance Weighted (IDW) void fill up to 15 pixels with a minimum of 30% valid elevations
Triangulation FILL_TRIANGULATION Fill large areas of missing data by triangulating the dataset
Clear Selection (Esc) SELECT_NONE Clear the select mask
Copy DATA_COMPONENT_COPY Copy minDEM and name it minDEM Original for use later in the process
Points to DEM POINTS_TO_DEM Create a raster of the standard deviation of the lidar points intersecting with a pixel of the raster being generated.
Set Active DEM ACTIVE Sets the standard deviation raster (stdDev) to active allowing editing
Select All (Ctrl-A) SELECT_ALL Select all DEM pixels for editing
Kernel→Inverse Distance Weighted FILL_IDW Fill small areas of missing data with an Inverse Distance Weighted (IDW) void fill up to 15 pixels with a minimum of 30% valid elevations
Triangulation FILL_TRIANGULATION Fill large areas of missing data by triangulating the dataset
Clear Selection (Esc) SELECT_NONE Clear the select mask
Points to DEM POINTS_TO_DEM Create a raster (count) of the number of lidar points intersecting with a pixel of the raster being generated.

Help references:

Load LIDAR | Data Management | Scripting | Table of Contents

3. Create 2D Land Use Classifications

The Classify Land Use script is used to define Ground, Water, Vegetation and Buildings in a raster mask. The water will be flattened and a 3D breakline will be generated around the water.

  1. Download Classify Land Use script
  2. Within the Scripting tab click Import
  3. Select the ClassifyLandUse.xml from the download location
  4. Within the Scripting tab click Run
  5. Select ClassifyLandUse and click OK
  6. View Results:
    • Right click the minDEM dataset in the TOC and select Check All
    • Right click Madison dataset in the TOC and select Uncheck All
    • Click into the data view and press H to turn of shaded relief colors CLASS mask is visible
    • Right click on hydroBreaklines in the TOC and select Check All
automated classification and hydro breaklines
Observe: The minDEM is a bare earth DEM with no missing data. The 2D land use classification indicating water, buildings and vegetation and the water is surrounded by 3D breaklines.

The following lists the uniDEM tools that are executed by the ClassifyLandUse script:
uniDEM Tool Name Script Tool Name Description
Select Values SELECT_RANGE Select Water where the count raster holds 0-1 lidar returns for each pixel
Clean Up SELECT_CLEANUP Remove "islands" - clean up all small holdes (<100m2) in the selection
Clean Up SELECT_CLEANUP Remove small water bodies - clean up all small selections (<100m2)
Assign Class CLASS_ASSIGN Assign selection to the Lake (23) classification
Make Void ASSIGN_VOID Void all selected lake DEM pixels in minDEM
Perimeter (Fill) FILL_PERIMETER Fill all selected lake pixels to the lowest 10th percentile of the shoreline (perimeter) elevations
Lock RASTER_LOCK Lock edited water DEM and CLASS pixels so values cannot change
(Convert) To Polygons MASK_TO_POLYGON Create 3D breaklines in shapefile format defining each water body
Select Values SELECT_RANGE Select values of 1-1000m which represent forests from the stdDev dataset
Erode SELECT_ERODE Erode selection by 2 pixels to remove building and other localized edges
Grow SELECT_GROW Grow the selection by 2 pixels to generally cover the forested regions
Blur→Percentile BLUR_PERCENTILE Blur the selections using a 5x5 kernel to the lowest 10th percentile to remove tree trunks
Select All (Ctrl-A) SELECT_ALL Select all pixels
(Auto) Bare Ground CLASS_AUTO_BAREGROUND Use the Bare Ground classification tool to segment all classes between Bare Ground (12) and Unknown (0)
Clear Selection (Esc) SELECT_NONE Clear the selection
Select By Class SELECT_CLASS Select all Unknown (0) classifications from the CLASS layer of minDEM
Clean Up SELECT_CLEANUP Remove all selected areas < 50m2 to define the smallest building area
Grow SELECT_GROW Grow the selection by 2 pixels to include building overhangs such as eaves
Keypad Preset - 6 (Building) CLASS_PRESET_6 Assign the selection to the Building (64) pixels
Select By Class SELECT_CLASS Select the Unknown (0) and Building (64) classifications
Make Void ASSIGN_VOID Void all selected pixels as they are not assumed to be bare ground
Grow SELECT_GROW Grow selection by one pixel around voided Building and Unknown classes
Blur→Percentile BLUR_PERCENTILE Smooth the selected edges of the voids using a 5x5 median filter (50%)
Kernel→Inverse Distance Weighted FILL_IDW Fill small void areas with an Inverse Distance Weighted (IDW) void fill
Triangulation FILL_TRIANGULATION Fill large void areas with the Tringulation void fill
Clear Selection (Esc) SELECT_NONE Clear the selection
Select By Class SELECT_CLASS Select the Building (64) classification
Lock RASTER_LOCK Lock the edited Building (64) DEM and CLASS pixels so they cannot change
Clear Selection (Esc) SELECT_NONE Clear the selection
Select Values SELECT_RANGE Select values of 1-1000m from the stdDev dataset which represent forests
Grow SELECT_GROW Grow selection by one pixel to capture forest holes and extents
Clean Up (Selection) SELECT_CLEANUP Remove small holes (<10m2) in the selected forest
Assign Class CLASS_ASSIGN Assign the selection to Medium Vegetation (14)
Clear Selection (Esc) SELECT_NONE Clear the selection
Select All (Ctrl-A) SELECT_ALL Select all pixels
Unlock RASTER_UNLOCK Unlock all DEM and CLASS pixels for minDEM
Clear Selection (Esc) SELECT_NONE Clear the selection

Help references:

Load LIDAR | Data Management | Scripting | Table of Contents

4. Classify Lidar Points

The Classify Lidar script is used to define LAS classification types:
  • Ground (2)
  • Building (6)
  • Water (9)
  • Low Vegetation (3)
  • Medium Vegetation (4)
  • High Vegetation (5)
  • Low Point Noise (7)
  • High Noise (18)
  1. Download Classify Lidar Script
  2. Within the Scripting tab click Import
  3. Select the ClassifyLidar.xml from the download location
  4. To observe the script modify lidar classes:
    • Right click the minDEM dataset in the TOC and select Uncheck All
    • Right click Madison dataset in the TOC and select Check All
  5. Within the Scripting tab click Run
  6. Select ClassifyLidar and click OK
Observe: The lidar points in the Madison dataset have been reclassified.
automated lidar classification and hydro breaklines

The following lists the uniDEM tools that are executed by the ClassifyLandUse script:
uniDEM Tool Name Script Tool Name Description
Select By Class SELECT_CLASS Select Medium Forest (14) from the 2D land use CLASS layer
(Classification) Set From DEM POINTS_CLASS_FROM_DEM Assign LAS classes in the selection based on their height above the bare earth DEM (minDEM)
LAS Class Minimum (m) Maximum (m)
Low Point Noise (7) -Infinity -1.0
Ground (2) -1.0 1.0
Low Vegetation (3) 1.0 2.0
Medium Vegetation (4) 2.0 5.0
High Vegetation (5) 5.0 50.0
High Noise (18) 50.0 Infinity
Clear Selection (Esc) SELECT_NONE Clear the selection
Select By Class SELECT_CLASS Select Lake (23) from the 2D land use CLASS layer in minDEM
(Classification) Set From DEM POINTS_CLASS_FROM_DEM Assign LAS classes in the selection based on their height above the bare earth DEM (minDEM)
LAS Class Minimum (m) Maximum (m)
Low Point Noise (7) -Infinity -1.0
Water (9) -1.0 1.0
Low Vegetation (3) 1.0 2.0
Medium Vegetation (4) 2.0 5.0
High Vegetation (5) 5.0 50.0
High Noise (18) 50.0 Infinity
Clear Selection (Esc) SELECT_NONE Clear the selection
Select By Class SELECT_CLASS Select Unknown (0) and Bare Ground (12) from the 2D land use CLASS layer in minDEM
(Classification) Set From DEM POINTS_CLASS_FROM_DEM Assign LAS classes in the selection based on their height above the bare earth DEM (minDEM)
LAS Class Minimum (m) Maximum (m)
Low Point Noise (7) -Infinity -1.0
Ground (2) -1.0 1.0
High Noise (18) 1.0 Infinity
Clear Selection (Esc) SELECT_NONE Clear the selection
Select By Class SELECT_CLASS Select Building (64) from the 2D land use CLASS layer in minDEM
(Classification) Set From DEM POINTS_CLASS_FROM_DEM Assign LAS classes in the selection based on their height above the bare earth DEM (minDEM)
LAS Class Minimum (m) Maximum (m)
Low Point Noise (7) -Infinity -1.0
Ground (2) -1.0 1.0
Building (6) -1.0 50.0
High Noise (18) 1.0 Infinity
Make Void ASSIGN_VOID Void the flattened buildings in minDEM so they can be replaced with the values from the minDEM Original dataset
Delta Surface FILL_DELTA_SURFACE Fill the voided building with the unedited elevations from minDEM Original
(Classification) Set From DEM POINTS_CLASS_FROM_DEM Assign all pixels greater than 2 meters from the closest DEM height to High Vegetation (5)
Clear Selection (Esc) SELECT_NONE Clear the selection

Help references:

Scripting | Table of Contents