QGis for LIDAR:colorizing from an image

Tutoriel : LIDAR HD avec QGIS 3.32

In this article you’ll find out how to transfer colors (colorize) from an image or orthophoto to the points of a LIDAR cloud using CloudCompare. The result is an orthophoto-like rendering that makes it easier to work with both unclassified clouds and classified data.

1- LIDAR data in QGis 3.32

2- Download LIDAR HD data from IGN and load it into QGis

3- Tools for LIDAR data in QGis 3.32

4-Colorize a point cloud from an orthophoto

Watch this video and many others on our Youtube channel: https://www.youtube.com/@sigterritoiresritoires

When you load LIDAR data into QGis, you are faced with two types of rendering.

In the case of unclassified data, you’ll either get a gray square if the symbology is set to classification:

display the classes of an unclassified point cloud

or a color gradient if you have a ramped symbology on an attribute (in this case, signal intensity):

display the signal intensity of a lidar cloud

In the case of classified data, the display of classes is a little (not much) more meaningful:

display of lidar classes

If we compare these renderings with an orthophotograph :


We have to admit that it’s much nicer to work on the latter type of rendering, where you see the objects as you’d normally see them.

Well, it’s perfectly possible to work with LIDAR point clouds with the same type of rendering as with orthophotography. One of the standard attributes of LIDAR points is the RGB attribute, which allows you to store a color value for each point. To display point colors, simply select the RGB symbology in the symbology tab of the layer properties.

lidar cloud qgis symbology by rgb

But, of course, these values must have been entered beforehand. And this is not the case with IGN HD data. So here’s how to transfer color values from orthophoto pixels to the corresponding points in the LIDAR point cloud.

To do this, you need your LIDAR point cloud and an orthophoto or other aerial image of the same area.

Colorizing LIDAR data with CloudCompare

In this chapter, we’ll use CloudCompare to perform the operation. In the next chapter, we’ll use the LAStools toolbox.

Why should we do this? Because the tool that performs this operation in LAStools is part of the paid-license processing. You can still carry out the processing, but the result is deliberately degraded by LAStools. Even if you can’t see the difference to the naked eye, let’s start with a treatment that will give you the best result for the best (free) price.

What’s more, processing with CloudCompare is fairly straightforward, but it does allow you to familiarize yourself with how it works. You’ll then be able to use CloudCompare for more complicated operations.

Click here to download CloudCompare.

Starting CloudCompare

Once installed, open the program.

cloudcompare start screen

Use the File->Open menu to load the point cloud to be processed: point to the file, click on Open, in the window that opens click on the Apply all button.

You’ll be presented with a window that deserves some explanation:

cloudcompare shift/scale screen

Before loading a file, CloudCompare analyzes the X, Y and Z coordinates. It calculates “offsets” for the coordinates so as to keep only the part that really varies over the extent of the work area. For example, in this window, it suggests subtracting the value -6225500 from the Y values, which are of the order of 6 million. This will produce significant Y values. Once processing is complete, in the resulting files, it will add the same value to the Y values obtained. This allows you to work only with significant values while preserving the true coordinates, but outside the processing.

For point clouds, you can simply accept the proposed values, which will always be correct.

You’ll find your point cloud in the main window, and when loading, the viewpoint is placed on top of the point cloud.

lidar display in cloudcompare

Use the mouse to display the cloud in any of three dimensions.
For a better view of the points, in the Properties panel, look for the Color Scale section and in Current select High contrast.

cloudcompare lidar display enhancement

Loading the orthophoto

Now let’s load the orthophotograph.

If you use the same procedure as for the point cloud, you’ll load the image as a tif file. For what we want to do, we need to load it as a point cloud. To do this, open the file manager, go to the image directory then click on the image file and drag it into the CloudCompare window.

This window will appear:

import message as point cloud

Click on Yes.

As with the point cloud, the shift/scale window appears.

image height correction in cloudcompare

Here we have a value to modify. You may have already realized that in the CloudCompare window we’re in a 3D box that looks like our real world but has its own references. Unlike a GIS, which will determine whether two points in two different layers are in the same place by comparing their XY coordinates, in CloudCompare this will be done by calculating the distance in the internal 3D references. When you want to assign an RGB value to a point in the point cloud, it will look for the nearest pixel in the image. But as we’re in a 3D world, this pixel isn’t necessarily the one with the same XY, it’s the one with the smallest XYZ distance. In rough terrain, this can be very different from the result you’d get with a GIS.

When we loaded the point cloud (see image above), the Z values were around 589 meters. Our orthophoto has no Z coordinates, i.e. it has Z values =0. If we were to leave the Z offset unchanged (with a value of 0), we can be sure that the nearest points would not correspond to the correct XY coordinates. We’ll shift the image pixels by 589 meters. This will bring the two layers very close together and minimize errors.

If we enter this value as 589, the image will be in the middle of the point cloud.

lidar and orthophoto display in cloudcompare

Pre-treatment for colorizing

You’d think we’d have all the ingredients we need for our colorization operation. But the problem is that we have two layers of dots, each with millions of dots. Finding the correspondence between these two layers would take far too much time. One way of significantly reducing this processing time is to create a TIN raster of our photo. Then we can use the vertices of the TIN to colorize our LIDAR cloud.

To create a TIN, click on the photo layer in the layer list, then on CloudCompare’s Raster tool.

rasterize button in cloudcompare

This brings up the raster transformation configuration window.

Except in exceptional cases, you’ll see an invalid grid box message in the size parameter. Don’t worry, click on the Edit Grid button and, in the window that opens, tick the keep square box, then click on OK.

raster grid correction cloudcompare

The step parameter indicates the precision of the grid. The default setting is 1 metre, which gives good results, but you can increase the precision, bearing in mind that this will increase processing times.

In Active Layer, select RGB

The direction parameter should be set to Z for horizontal interpolation and the cell height you can leave at minimum or change it, but it won’t really make a difference.

Click on Update grid and you’ll see a preview of the result

grid to be used for cloudcompare rasterization

You can uncheck Export statistics, then click on Mesh to start creating the TIN.

You’ll see the TIN added to the list of project layers. You can then close the rasterization window.

You can uncheck the original ortho in the layer list to see the TIN that will be used.

Colorizing the point cloud

Now we’re ready to transfer the colors from the TIN to our LIDAR cloud. Select the vertices layer and the Lidar layer

layer selection for colorization

To colorize, we’ll use the Edit -> Color -> Interpolate from another entity menu.

interpolate from another entity cloudcompare

As soon as you click on the menu, the command is executed.

start colorize processing

CloudCompare doesn’t ask which layer is the source and which is the destination. It assumes that the source layer is the one with RGB values and the destination layer is the one without. If both have values set, you must first use the CLEAR command on the destination layer..

clear colors menu cloudcompare

The result of our command, after waiting patiently for processing to finish, is:

result colorize cloudcompare

All that remains is to export the result as a .las or .laz file

Select the original LIDAR layer, which now has RGB values, then in the File->Save menu. Enter a name (here resultat) and the desired extension (.las or .laz). You’ll have your new, colorized LIDAR cloud ready for loading into QGis:

display colorize qgis

Zoom in to see the colorized points.

zoom display colorized cloud in qgis

Si cet article vous a intéressé et que vous pensez qu'il pourrait bénéficier à d'autres personnes, n'hésitez pas à le partager sur vos réseaux sociaux en utilisant les boutons ci-dessous. Votre partage est apprécié !

Leave a Reply

Your email address will not be published. Required fields are marked *