QGis for LIDAR:digital terrain model (DTMIn this article you will find the definition of a digital terrain model and, step by step, how to create a DTM from an unclassified and classified LIDAR cloud, using CloudCompare and QGis.
Tutorial HD LIDAR data processing with QGis
7- digital terrain model (DTM) with CloudCompare
A Digital Terrain Model (DTM) and a Digital Surface Model (DSM) are two types of digital representation of an environment, usually based on LiDAR data. Although they are often used interchangeably, they capture different information about the landscape. In the previous article we saw how to generate a DSM with CloudComapre or LAStools. Here we’ll look at how to generate a DTM with CloudCompare, and in the next article how to do it with LAStools.
Digital Terrain Model (DTM):
A Digital Terrain Model (DTM) represents the actual topography of the ground beneath all features present on the surface, such as vegetation, buildings or man-made objects. It is essentially the natural terrain, stripped of all structures and elevated features that are not part of the underlying topography. A DTM is generally obtained by filtering or classifying LiDAR points to retain only those that correspond to the ground. In this way, the DTM is closer to the actual topography, providing valuable information for geomorphological analysis, hydrology, slope mapping, etc.
Digital Surface Model (DSM):
A Digital Surface Model (DSM) represents the visible surface of the landscape, including above-ground features such as buildings, vegetation, vehicles, etc. Unlike DTMs, DSMs do not filter out above-ground objects and therefore capture the entire topography, including structures and elevated features. Unlike DTMs, DSMs do not filter out above-ground objects, and therefore capture the entire topography, including structures and elevated features. The LiDAR data used to create a DSM therefore includes all features present, making it a more complete representation of the landscape as seen from above.
Differences between DTM and DSM :
- Content: DTM only includes points that correspond to the ground, whereas DSM includes all points above ground, including objects and structures.
- Uses: DTM is often used for geomorphological, hydrological, geological and land-use planning analyses. DTM is used for visual modeling, urban mapping, natural resource management and other applications requiring a complete view of the surface.
- Analysis: DTM can provide precise information on the actual topography of the ground, while DSM enables above-ground features such as buildings and vegetation to be visualized and analyzed.
In short, the Digital Terrain Model (DTM) focuses on natural terrain and eliminates above-ground features, while the Digital Surface Model (DSM) includes all elevation features. Each of these models has its own specific uses, depending on analysis and visualization needs.
Creating a DTM from a classified cloud with QGis
In a classified cloud, we already have the information we need to generate a DTM: class 2 – Soil. In fact, all points corresponding to above-ground features (buildings, vegetation, etc.) belong to other classes.
We can therefore create a raster layer by selecting only the points in class 2.
We’ll be using a cloud of IGN LIDAR HD classified points:
Where we will retain only the points classified as ” Ground “:
To do this, we’ll use one of the new tools applicable to point cloud layers: Export to raster (using triangulation).
In Resolution of the density raster, select the output mesh size.
In Advanced parameters -> Filter expression we select Classification = 2, to retain only points of class 2.
We enter a name for the output file (here groundIGN.tif) and execute the command.
The most effective visual way of determining DTM quality is to use the Elevation Profile View:
In blue we see the DTM we’ve just calculated.
Creating a DTM from an unclassified cloud with QGis.
For this part of the article, we’re going to work on the same point cloud as before, but with the classification removed. We then find ourselves with all points in a single class 0.
We therefore need a tool that will enable us to separate the points corresponding to the ground from the rest of the points. There are several, but we’ll start with CloudCompare, which seems to me to be the “best”, as it allows us to perform this task by visualizing the various stages of testing. These tests are necessary because we need to adapt the parameters of s treatments to each cloud according to several criteria.
DTM calculation with CloudCompare.
The CSF (Cloth Simulation Filter) is a filtering algorithm used in CloudCompare software for processing lidar point clouds. It is primarily used to remove noise and outliers from point clouds, particularly in areas where complex surfaces such as trees are present, but also to distinguish between ground and overground points.
The CSF filter takes its name from cloth simulation, because of the way it models the structure of the point cloud. The basic idea behind the CSF filter is to model points as being attached to virtual “fabrics” that bend and deform according to the density of points in the surrounding areas. Areas where the “fabrics” are highly deformed are considered to have complex surfaces, such as vegetation or buildings.
Here’s how the CSF filter works in CloudCompare:
- Calculating normals: The CSF filter starts by calculating the normals of the points in the cloud. Normals are vectors perpendicular to the points’ local surfaces.
- “Fabric” creation: The filter divides space into a 3D grid and assigns each point to a virtual “fabric” according to its position and normals.
- Fabric simulation: The filter simulates how these “fabrics” would react under forces such as gravity. The “fabrics” bend and deform according to the density of the points around them.
- Noise detection: Areas where “fabrics” are strongly deformed are considered noise zones or complex surfaces. Points associated with these areas are labeled as off-ground.
- Filtering: Points marked as off-ground are removed from the point cloud, leaving behind a filtered and cleaned version of the cloud.
The CSF (Cloth Simulation Filter) in CloudCompare can be used to separate ground points from other points in a LiDAR point cloud. This is particularly useful for isolating real terrain topography from elevated features such as buildings, vegetation or other structures.
It’s important to note that the success of using the CSF filter to separate ground points from others will depend on the parameters you choose and the complexity of the landscape. It may be necessary to adjust the filter parameters several times to obtain the best results.
It’s important to note that the success of using the CSF filter to separate ground points from others will depend on the parameters you choose and the complexity of the landscape. It may be necessary to adjust the filter parameters several times to get the best results.
We start by loading our unclassified point cloud into CloudCompare:
Open the CSF filter window from the Plugins->CSF Filter menu.
You have the plugin window with a first parameter to determine, the slope type of the terrain. There are three types:
- flat terrain
- hilly terrain
- very hilly terrain
In our case, the terrain is hilly.
Next, go to the Advanced parameters settings tab.
The two parameters to set are:
The “Cloth resolution” parameter in CloudCompare’s CSF (Cloth Simulation Filter) refers to the size of the three-dimensional grid used to model virtual “cloth” in the simulation process.
When you apply the CSF filter to a point cloud, it divides the space into smaller regions using a 3D grid. Each region is considered a virtual “cloth” that reacts to applied forces, simulating the movement and deformation of a real cloth. The “Cloth resolution” parameter controls the size of this grid.
Higher resolution means the grid will be finer, enabling the CSF filter to better capture subtle details and variations in the point cloud. However, higher resolution can also increase computation time and resource consumption.
A lower resolution means that the grid will be coarser, which may speed up the calculation process, but risks missing some of the finer details in the point cloud.
The choice of resolution will depend on the complexity of your data, the size of the point cloud and the purpose of your analysis. If you’re working with complex areas, a higher resolution may be desirable to capture detail. If you have a large point cloud and need results more quickly, a lower resolution may be appropriate.
As always, it’s advisable to experiment with different resolution values and visually check the results to determine which resolution works best for your specific data.
The “Classification threshold” parameter in CloudCompare’s CSF (Cloth Simulation Filter) is used to specify a deformation threshold beyond which points in the point cloud will be considered unclassified, i.e. assigned to the off-ground.
When the CSF filter is applied, it simulates the deformation of a three-dimensional grid (representing virtual “fabrics”) based on the cloud points. Areas where fabrics are highly deformed are interpreted as areas with complex features, such as vegetation or elevated objects.
The “Classification threshold” parameter is used to control the maximum deformation tolerated before a point is considered out-of-ground. In other words, if a point’s deformation exceeds the specified threshold, it will not be assigned to the “particular “ground class, marking it as potentially “out of ground”.
Adjusting the “Classification threshold” parameter can control the level of detail that the CSF filter will use to differentiate between complex soil characteristics. A higher value will make the filter more sensitive to complex features. A lower value will make the filter less sensitive and can be used to filter only very pronounced features.
As always, it’s advisable to experiment with different threshold values and visually check the results to determine which value works best for your specific data.
Generally speaking, we consider that the Classification threshold value should be double the Cloth resolution value.
So here we are, off to the races. A good starting point is to set the Cloth resolution to 0.2 meters and the Classification thresholds to 0.4 meters.
We run the filter and find a new result layer in CloudCompare with two sub-layers:
The first contains the points classified as “ground” by the CSF filter.
The second contains points classified as “above ground” by the CSF filter.
We’re going to try a new combination of parameters to refine the detection of above-ground points. To do this, we’re going to activate the “ground” layer we’ve just calculated and apply the csf filter to it, with Cloth resolution set to 0.4 metres and Classification thresholds set to 0.8 metres.
We’ll then have two new layers, one with points that are considered “ground” and the other with points that had been considered “ground” by the first pass of the CSF filter but are now considered “above ground” with the new parameters.
We have the “ground” layer
EAnd we have the points that are now “off-ground”.
Visually, we can already say that our result should be satisfactory. But to be sure, let’s repeat the operation a third time, this time with Cloth resolution at 0.8 meters and Classification thresholds at 1.6 meters.
We’ll then have two new layers, one with points that are considered “ground” and the other with points that had been considered “ground” by the second pass of the CSF filter but are now considered “above ground” with the new parameters.
We have the “ground” layer
Where you now see fairly extensive areas without any points.
And the “off- ground” layer
To be able to validate the right combination of parameters, we save the resulting “ground” layers as point clouds. You can save the filtered point cloud by selecting “File” > “Save As” from the menu to save a new copy with the modifications made by the CSF filter.
We now have three new point clouds, ground02… for the result of the first CSF filter, ground04… for the second and ground08… for the third, which we load into QGis. We also load the original unclassified point cloud, nc…
Intuitively, the result of filter 0.4 seems the best. Filter 0.2 has a little too much “ground” and filter 0.8 not enough in some areas.
We can now create the three DTMs and compare the result with the original point cloud.
To do this, as in the first example, we use the Export to raster (using triangulation) tool. However, as here we only have points corresponding to the ground, we don’t need to apply a filter. We simply define the mesh spacing of the output DTM and the name of the output file.
We then have three rasters with the corresponding DTMs
As you can see, in DTM 0.2 we can still see the footprints of buildings classified as “soil”. To see the difference between DTMs 0.4 and 0.8, we use the Elevation Profile View.
We display the original point cloud and the DTM calculated from IGN’s “ground” class. We consider this DTM to be the best DTM.
On this profile we have terrain features, low and high vegetation and buildings.
If we display DTM 0.2 in yellow, we have:
Low and high vegetation have been classified as “above ground”, but buildings are still included in the “ground” points.
If we display DTM 0.4 in blue, we have:
The buildings are now excluded, and the result merges with that of the IGN.
Finally, if we display the DTM 0.8 in red, we have:
By excluding points which are part of the terrain, we have created empty zones which are then interpolated with only the edges of the zones. We still have a good terrain calculation in areas of vegetation and buildings, but some terrain features disappear.
In conclusion, our parameters with Cloth resolution at 0.4 meters and Classification thresholds at 0.8 meters, which we had thought to be the best combination since the calculation of the CSF filter in CloudCompare, turn out to be the best. They enable us to obtain a DTM equivalent to that calculated from IGN classified data.