Marco Lurati

3D terrains from height maps

- >

  • 3D printing
  • 3D terrain
  • maps

Height maps

The geodata on the swiss topography office are available to download for free and the one necessary to generate a 3D terrain are the ones called swissALTI3D.

The data necessary to generate the 3D model are called "heights maps" and they are usually greyscale images. Every pixel in the image carries three information; latitudinal and longitudinal coordinates (related to its x and y position in the image) and the elevation of the terrain in that specific point defined by the greyscale value of the pixel itself.

The 3D model is generated using those information of the height map image.

The main program required is QGIS with the DEMto3D extension both opensource and free to use. Later on will be showing how to install them.

Get the maps form swissALTI3D

From the website swissALTI3D the online tool allows to select in different ways the desired areas to export. With the "Selection mode" drop down menu, choose the one that best works for you.

The "Selection by rectangle" allows to select a bigger area by clicking on the button "New rectangle" and dragging it on the map. The map can be zoomed in by scrolling in and out and right click of the mouse to pan around.

About the available options; the format I would suggest to use is "Cloud Optimized GeoTIFF" and a resolution of 2 meters. The 0.5 meter is very very dense and for bigger areas is way too heavy to handle later on. For smaller areas it's a good choice to keep all the details.

The last step is to click on "Search" to generate the list of the tiles of the map selected. Download them on your computer.

QGIS setup


Download and install QGIS. Once installed, form the menu bar click on "Plugins > Manage and install Plugins ..." and all the available plugin list will appear. Search for "DEMto3D" and install it. You are all setup now.

QGIS maps preparation

The TIFF images that has been downloaded has to be loaded as Layers in QGIS. Form the QGIS interface you can browse your folders from the "Browser" box and select all the map tiles and drag them in the "Layers" box to load them and show them. You can also drag them from you computer to the Layer box as well, even easier.

The height maps are shown as single tiles, and everyone has a different grey scale gradient that doesn't match with the other one. As a reminder the grey values indicate the vertical elevation of the terrain.

To make them all use the same grey scale to properly match, the next step is to merge them to have a uniform greyscale gradient among all the map.

From the main menu bar, select "Raster > Miscellaneous > Merge...". A new window appears. At the moment there are no Input layers selected, to select them click on the button with the three dots next to the "Input layers". From there click on "Select All" to add all the layers.

Click on the back arrow next to "Input layers" to go back. Now just press the "Run" button at the bottom of the window, and you will see a new "Merged" layer appear in the list. Close the Merge window.

DEMto3D model generation

From the main menu select "Raster > DEMto3D > STL DEM 3D printing" to load the plugin.

Layer to print
First thing to do is to select the interested layer to use, in this case select form the list the Merged one.

Print extent
The print extent define the portion of the map to include, by clicking on the magnifying loop button with the green arrows you will select the whole map of the layer. With the other magnifying loop buttons you can select just a portion.
By activating the "Show width/length" you will see the terrain width and length selected in meters.

This will define the dimension of triangles of the generated mesh of the STL file (let's say it does control the resolution of the mesh). Smaller it is, more resolution you will have, but way more complex to generate and difficult to work with it will be. The weight of the file will also increase (easily reaching some GBytes in size!). If your PC freezes, maybe you need to increase this value in order to be able to generate the 3D model.

Width, Length and Scale
those are linked together, change one to update the others. They define the final dimension of the model, if you are gonna to 3D print it check that the maximum size will fit on your printer bed. You could also specify a scale if you are gonna to truthfully reproduce it.

Vertical exaggeration
in case you want to emphasize the depth of the 3D model you can increase this value, be aware that it won't be in a real scale and the Z vertical axis will be stretched. With x 1,000 the scale is correct.

Terrain inversion
you can generate the negative of the terrain with this option.

Divide model
If you need a specific scale and size of the final terrain but it won't fit into you 3D printer or CNC, you can divide it in tiles (separate files) and print/cut them separately and assemble them afterwards.

Height (m)
You can define from witch elevation upwards you want to generate the model. On the left side you can see the "Lowest point" of the current map. If you want to include all of that you can choose a lower value.

For example if the lowest point is 1635m you can choose 1500m as height to start from to include a vertical margin in the model corresponding to 135m, and have all the map included in the 3D model.

On the other hand, if you are only interested on an higher portion of the map, you can start form an higher height, for example 2000m, just be sure to still be lower than the "Highest point" else there won't be any terrain to generate. In this example with an height of 2000m, you will have 658m of vertical terrain in your model (the Highest point is indicated as 2658m).

!!! Small caviar of the plugin !!!
Once you inserted the "Height (m)" value, you have to press the Enter key in order for the plugin to calculate the "Model height". If you don't do that, the model height will stay at 0mm, and you model will result flat (useless). So be sure to press Enter and properly have a defined Model height other than 0mm.

Once you have filled up all the parameters, click on the button "Export to STL" to generate the 3D STL model. Once the model is generated, the plugin will notify you with a popup window.