From Digital Terrain Model to Point Cloud: How to Convert IGN DTM to 3D Models

0
1569

Since our National Geographic Institute (IGN), in conjunction with the National Center for Geographic Information (CNIG), began the PNOA project (National Aerial Orthophotography Plan) around 2008, DTMs have become an easily accessible resource whether for GIS work, terrain study, or simply for 3D landscape modeling tasks.

A DTM is described as “a statistical representation of the terrain, in the form of digital numbers, through a set of points with x,y,z coordinates relative to a known georeferenced system,” that is, a DTM is a document with information on terrain elevation (Z axis) relative to a coordinate system. The problem with these documents is that they usually do not contain X and Y information associated with each Z value, which is necessary for us to understand them as a complete 3D model (point cloud).

Our IGN provides DTMs in Esri ASCII Grid (.asc) format obtained by LIDAR or Photogrammetric flights from PNOA. The available resolutions are MDT05, MDT25, and MDT200 with grid sizes of 5, 25, or 200m respectively. All these documents can be easily located through the IGN download website where we can search by locality, province, etc., or through the well-known MTN50 numbering of the IGN, where it will undoubtedly be easier to locate our areas of interest.

Esri ASCII Grid DTMs, as their name indicates, are encoded in plain text (ASCII) so we can easily open them with a text editor and observe their characteristic headers:

  NCOLS 1121
  NROWS 769
  XLLCENTER 511600
  YLLCENTER 4723600
  CELLSIZE 25
  99.201 100.982 103.968 06

Since .asc files are grids, these headers specify the number of columns and rows (NCOLS and NROWS), the coordinates relative to the center of the grid (XLLCENTER and YLLCENTER), and finally the grid width (CELLSIZE) as well as a long string of numbers corresponding to the elevations.

Along with the DTMs, we can also download other types of documents such as orthophotos or the well-known MTN sheets in raster or vector format.

To work with the Esri ASCII Grid format, we could directly use Esri’s ArcGIS tool, but since it is proprietary software, we will use the free tool gdal_translate belonging to the GDAL (Geospatial Data Abstraction Library) suite of tools, available for all operating systems.

Installation on Mac OS X

If we are using Mac OS X, we can download the binaries and then just add the GDAL framework path to our path; on this URL we can find information about the process:

echo 'export PATH=/Library/Frameworks/GDAL.framework/Programs:$PATH' >> ~/.bash_profile
source ~/.bash_profile

Installation on Linux (Ubuntu)

On Ubuntu, if we install from the repositories, it is likely that it will not install the latest version, so it is also likely that the “translate” function is not available. For this, we download at least version 1.11 from:

http://download.osgeo.org/gdal/1.11.0/

Then we execute the typical compilation sequence:

./configure
make
sudo make install

And finally, if we run:

gdalinfo --version

And it throws an error related to the library libgdal.so.1 not being found, we must run ldconfig:

cd /etc/ld.so.conf.d
sudo ldconfig

This process will launch the configuration and it should work afterwards.

Once GDAL is installed, we simply run:

 gdal_translate -of XYZ MDT05-0120-LIDAR/MDT05-0120-H29-LIDAR.asc MDT05-0120-LIDAR/MDT05-0120-H29-LIDAR.xyz

The conversion process simply takes the coordinates of the grid center and extrapolates them to the rest of the elevation values. If we examine the generated XYZ document, we will observe the XY values corresponding to the coordinates of our grid and Z as the elevations:

  511600 4742800 99.2009963989257812
  511625 4742800 100.982002258300781
  511650 4742800 103.968002319335938

In this way, we already have elevation data accompanied by X and Y coordinates and ready to be loaded into any 3D modeling tool. In our case, to continue the process, we will use MeshLab.

MDT asc to wireframe Once our XYZ model is loaded in Meshlab, we go to Filters > Point Set > Surface Reconstruction: Poisson, and enter the Octree Depth value of 10 and Solver Divide of 8, although it is possible to enter other values if we want more simplified models.

After applying this filter, we already have our DTM in the form of the typical 3D mesh which we can easily illuminate or apply a texture to.

To continue with the exercise of working with DTM in Meshlab, we will apply a texture to this model with a raster image formed by an MTN sheet corresponding to a region of my DTM.

MTN sheets come in TIFF format, so they must be converted to JPG or PNG to be used with Meshlab. Next, we go to File > Import Raster, so that our image is loaded into the Meshlab layout. We must reset the Trackball to recover our model in the layout.

alignNext comes the most arduous task, which is to fit our 3D model with our raster image by zooming in and out of the model or moving it until the image fits the relief. To successfully complete the process, we should locate obvious geographic points between the model and the MTN sheet or orthophoto to make them fit. Using the right mouse button and its wheel, or on Mac the Ctrl key, we can modify the transparency of our raster image to check the level of alignment between raster and 3D model.

register_cameraNext, we need to “register” our raster image as a camera; for this, we go to Filters > Camera > Set Raster Camera, leave the Current Trackball option, and activate Get Shot and Apply to establish the relationship between camera and model. This step is important; otherwise, our raster image will not be properly registered as a camera.

Next, we go to Filters > Texture > Parameterization + Texturing from Registered Rasters, and simply choose the resolution of our UV map, which is fundamental to preserve the detail of our MTN sheet or orthophoto, and the texture name.

mdt asc meshlab With these simple steps, we already have a 3D model formed by a mesh, with its texture formed by a UV map taken from an orthophoto, topographic map, etc., …

With GDAL, we can see how easy it is to have an XYZ model from ASC documents with elevation information. It is worth mentioning that gdal_translate allows us to perform dozens of conversions between documents with geographic information, so it is worth exploring it as a tool of very high potential if we work with 3D models or GIS.

MDT to rasterFor example, if we use the “-of JPEG” or “-of PNG” option, we can export our DTM as a raster image, as we can see in the image on the left.