Native point cloud processing in QGIS

MAY 30, 2023 crowdfunding pointcloud qgis

After the addition of support for visualising point clouds in the recent versions of QGIS, the next step was to add the processing tools so users can manage and analyse their data.

There are several 3rd party QGIS plugins (either proprietary or not fully open source) which allow users to interrogate and analyse lidar data. But with our latest work, we have introduced powerful point cloud algorithms to the QGIS Processing framework. All the algorithms are available out of the box in QGIS 3.32, with no need to install plugins.

In this blog post, we summarise the initial point cloud algorithms for QGIS Processing toolbox which will be available in QGIS 3.32 (to be released at the end of June 2023). This work was made possible by the generous donations to our crowdfunding.

Point Cloud algorithms in QGIS

First off a quick look at the new algorithms as shown in the Processing toolbox in three groups:

Point Cloud algorithms in QGIS processing toolbox

Point Cloud algorithms in QGIS processing toolbox
  • Convert formats: this will allow you to convert your point cloud data between LAS and LAZ formats for the time being. Other PDAL supported formats can be added later.
  • Export to raster: with this algorithm you can export point cloud to a regularly gridded raster data. It uses inverse distance weighting to assign raster cell values. Raster cells with no nearby points will get “no data” values (these holes may be removed by using “Fill nodata” raster algorithm).

Input point cloud layer file

Input point cloud layer file

Raster output using Intensity attribute of points

Raster output using Intensity attribute of points
  • Export to raster (using triangulation): this allows you to export Z data to a regularly gridded raster by interpolating between the points using triangulation. Note that this can be slower if you are dealing with a large dataset. If your point cloud is dense, you can export your ground points as a raster using the Export to raster algorithm.

Terrain raster output generated by point cloud triangulation

Terrain raster output generated by point cloud triangulation
  • Export to vector: to export point cloud to other vector formats. This is useful to export some of your data for software applications which do not support point cloud data and still use formats such as CSV, Shapefile, DXF.

Exporting point cloud (ground points) to Shapefile styled based on the elevation

Exporting point cloud (ground points) to Shapefile styled based on the elevation!
  • Assign projection: assigns a projection to a point cloud layer (if it is wrong or missing)
  • Build virtual point cloud (VPC): with this algorithm you can generate a virtual file (based on STAC specification) and load them as a single file in QGIS. There will be a separate blog post detailing this new exciting feature.
  • Clip: clip a point cloud layer by a vector polygon layer.

Input point cloud layer and a polygon coverage

Input point cloud layer and a polygon coverage

Result of the clipping algorithm

Result of the clipping algorithm
  • Create COPC: when you load a non-indexed point cloud layer in QGIS, it will take a while for the application to create the COPC index for your file. With this algorithm, you can create the index for all your files in a batch mode.
  • Information: displays information from a point cloud layer:
LAS           1.4
point format  6
count         56736130
scale         0.001 0.001 0.001
offset        431749.999 5440919.999 968.898
extent        431250 5440420 424.266
              432249.999 5441419.999 1513.531
crs           ETRS89 / UTM zone 34N (N-E) (EPSG:3046)  (vertical CRS missing!)
units         horizontal=metre  vertical=unknown

Attributes:
 - X floating 8
 - Y floating 8
 - Z floating 8
 - Intensity unsigned 2
 - ReturnNumber unsigned 1
 - NumberOfReturns unsigned 1
 - ScanDirectionFlag unsigned 1
 - EdgeOfFlightLine unsigned 1
 - Classification unsigned 1
 - ScanAngleRank floating 4
 - UserData unsigned 1
 - PointSourceId unsigned 2
 - GpsTime floating 8
 - ScanChannel unsigned 1
 - ClassFlags unsigned 1

Output from point cloud information algorithm

  • Merge: join multiple point cloud layers into a single file
  • Reproject: reproject the input file to a different coordinate reference system
  • Thin (by sampling radius): reduces the number of points within a certain radius

Thining point cloud (by sampling radius)

Thining point cloud (by sampling radius)
  • Thin (by skipping points): reduces the number of points by skipping nearby points
  • Tile: this algorithm generates a set of tiles based on the input point cloud layer and tile size
  • Boundary: generates a (multi) polygon from your point cloud data. The output file might contain holes depending on the density of your point cloud input data.

Extracting high vegetation and building polygons from an input point cloud layer

Extracting high vegetation and building polygons from an input point cloud layer
  • Density: outputs a raster file based on the number of points within each raster cell - useful for quality checking of point cloud datasets

Point density (number of points per 2x2 m)  as a raster

Point density (number of points per 2x2 m) as a raster
  • Filter: it creates a new file based on the filter set as an expression. Note that most of the algorithms support on-the-fly filtering under the Advanced parameters.

Filtering of high vegetation class from an input point cloud layer

Filtering of high vegetation class from an input point cloud layer

Behind the scenes

All the heavy lifting of the point cloud processing is done by PDAL - a state of the art open source library for processing point clouds. PDAL provides a wide range of “readers”, “filters” and “writers” to build complex pipelines to process point clouds.

We have built a new standalone command line tool pdal_wrench on top of PDAL. It addresses two major issues that non-expert users typically face when working with PDAL:

  • Ease of use: not everyone finds it easy to manually craft JSON files with pipelines, study manuals of the many stages and read details about file formats involved.
  • Parallel execution: PDAL runs pipelines in a single thread, so only one CPU gets to do the work normally and users need to implement their own parallelism if they want to speed up processing.

The command line tool provides a simple set of commands that take care of everything. For example, to export a raster layer with elevations (DEM) with 1 meter resolution:

pdal_wrench to_raster --output=raster.tif --resolution=1 --attribute=Z data.las

The pdal_wrench tool does not depend on QGIS, so it can be easily used separately.

The commands are designed to run in parallel when there are multiple input files or when the input file is in COPC format. Depending on the algorithm, the work gets split spatially into square tiles (1000x1000 map units by default) for parallel processing, or individual files are processed in parallel. With a single ordinary LAS/LAZ file on input, there is currently no parallelism going on.

For commands that are sensitive to edge artifacts (such as export to raster), we take care of processing extra points outside of the extent of each tile (referred to as collar or buffer) to make sure the results are correct as if no tiling would be happening (see Martin Isenburg’s article for more details: https://rapidlasso.com/2015/08/07/use-buffers-when-processing-lidar-in-tiles/).

Future work

The current list of point cloud algorithms already allows users to do plenty of work. But more could be added to the toolbox - algorithms that are already supported by PDAL, but not exposed in QGIS: classification, noise removal, surface reconstruction, clustering, height above ground, colorizing and many more. If you are interested in more point cloud processing algorithms in QGIS, please contact us and we will be happy to add them to future QGIS releases.


Posted by Martin Dobias, Saber Razmjooei