LAStools, PDAL and other command line tools

The most powerful tools for processing lidar data are mainly command-line.

LAStools (by the late Martin Isenburg) are the industry standard. Some of the tools are open source, some will function in “demo” mode when unlicensend and leave a watermark or add some noise to the data. They are commercialized by Rapidlasso but fairly expensive for hobby use. There’s also a basic GUI wrapper for most tools.

PDAL is a powerful open-source toolset that comes bundled with QGIS. While PDAL can perform most of the functions of LAStools it’s generally slower and less user-friendly. PDAL_wrench is a development built on top of PDAL that makes the tools more user-friendly, faster and tightly integrated into QGIS but at the time of writing the feature set is still limited.

Fusion toolbox and WhiteBoxTools are 2 other (mostly) open-source toolsets. For all 4 toolsets QGIS plugins are available, requiring some configuration.

LAStools

A nice overview of the tools can be found here. Each tool is documented extensively online (or add -help after a command). Add the location of the LAStools ‘bin’ folder to your system path. The following tools are fully functional without a license:

  • Show information about a lidar file:
    • lasinfo -i inputfile.laz
  • Convert a single .las file to compressed .laz format:
    • lasmerge -i inputfile.las -o outputfile.laz 
  • Merge several .las files into 1 compressed .laz, retaining only ground, road and bridge points (classes 2, 11 and 17):
    • lasmerge -i inputfile*.las -o outputfile.laz -keep_class 2 11 17
  • Reproject from one CRS into another:
    • las2las -i inputfile.laz -o outputfile.laz -epsg 1234 -target_epsg 4567
  • Add coordinate information into lidar file (without reprojecting):
    • las2las -i inputfile.laz -o outputfile.laz -epsg 2154
  • Re-assign all points from class 1 to class 6:
    • las2las -i inputfile.laz -o outputfile.laz -change_classification_from_to 1 6
  • Create shapefile on contours of .laz file, closing holes max 1m:
    • lasboundary -i inputfile.laz -oshp -concavity 1 -disjoint
  • Move all points 2,5m upwards (in a file with dimensions in meters):
    • las2las -i inputfile.laz -translate_z 2.50 -o outputfile.laz
  • Calculate average density and spacing of a .laz file:      
    • lasinfo -i inputfile.laz ^ -nh -nv -nmm -cd
    • lasinfo -i inputfile.laz -compute_density
  • Lasview: for visualizing (but CloudCompare is a lot more practical)

PDAL

To use PDAL: start the “OSGeo4W Shell” from the menu or the QGIS folder on you desktop. Some small operations can be launched straight from the command line but many operations require setting up a pipeline in a .json file. Some examples are provided below.

Several operations (like thinning) require loading the entire dataset into memory. If you run out of memory (bad allocation error): increase your system virtual memory by increasing the swap space. This will also increase the size of your hibernation file and may make your system disk fill up: temporary disable hibernate using the command powercfg -h off

To work around memory limitations the data is often split into tiles. However, some operations may generate artifacts towards the edges and logically require a temporary buffer around the tile for proper processing. This is implemented in licensed LAStools but not in PDAL yet (partially in PDAL wrench)

  • Split lidar file into tiles:
    • pdal tile file.laz “file_tile#.laz” –length 1000 > tile side length 1000m

  • Colorize a lidar file:
    • Obtain an orthopic of required resolution in the correct CRS (using QGIS)
    • Download & extract provided .json file into the folder with your lidar & orthopic
    • Either modify the “input”, “output” and “aerial” filenames in the .json, or modify your filenames
    • Run pdal pipeline colorize.json
    • If this doesn’t work, or you get a very small lidar file: probably CRS of the lidar & orthopic don’t match

  • Generate a rasterized elevation model (DEM):
    • Use the original (merged) lidar data, not thinned
    • Download & extract provided .json file into the folder with your lidar
      • The .json is set to use only class 2 = ground = DTM
    • Modify “input” and “DEM” filenames in the json and resolution (set to 1m in the json, if lidar is set in meters)
    • Run pdal pipeline las2dem.json
    • Alternatively it’s also possible to substitute parameters on the command line this way:
      • pdal pipeline Las2DEM.json –readers.las.filename=mylidarfile.laz \ –writers.gdal.resolution=10 \ –writers.gdal.filename=mydemfile.tif
    • More information on handling the resulting DEM file in this PDAL workshop