Convert a GeoTIFF to DEM

So one way I utilise GIS software is a very simple one: Sometimes I want to create a 3D model of something, let's say an acient building. This building is of course part of a wider landscape. Naturally, I would like to put the reconstruction of the building in its natural environment. Maybe the building was sitting on top of a mountain or deep in a valley. This might be important for the overall image I create. GeoTIFFs can help here, but Cinema 4D ist not capable of reading them directly. Additionally, they do not inlcude satellite data, that is needed for texturing.

Get a GeoTIFF

So the first step would be to get a GeoTIFF. You can get them anywhere, but to have a start, just head over to this website, where they offer free GeoTIFFs from Italy. Click on one of the squares and you download a ZIP. When finished downloading, unzip the archive. Inside, you will find a single TIF file. This is your GeoTIFF!

Startup QGIS and install packages

So the first step is to start QGIS and install some additonal packages that we will need. Maybe you already have them installed, but if your installation is fresh like mine, you haven't. Go to Plugins/Manage and Install Plugins.... In the search bar, search for HCMGIS. Click on it in the results list and hit Install Plugin. Done, you have now an additional menu option called HCMGIS.

Start a new project by clicking on the empty page in the buttons bar on top, by hitting CTRL+N or going through the menu to Project/New. You have now a big emtpy Main Window and a Browser as well as a Layers list on the left. Drag and drop your GeoTIFF into the Layers list.

If you look around the GUI, you'll notice that there is a lot of stuff going on. It is overwhelming, but we will focus only on these things that we need. So follow everything step-by-step and you will be fine. So far, you should have managed to open the software and load our GeoTIFF into the main window. That is a good start!

Add a terrain map and layout

With the plugin installed and GeoTiff loaded, we can add some free satellite data. Go to the menu under HCMGIS/Basemaps/Esri Imagery and you will see satellite data overlaying our GeoTIFF. What is great though is, that it automatically picks out the right satellite data, so it fits perfectly.

So let's say you want to have a special area of the GeoTIFF as DEM and the same area as a texture from the satellite data. With these two images, you can easily build a textured terrain model in Cinema 4D. To do so, we first create a new print layout under Project/New Print Layout.... Enter a unique name that makes sense. On the left toolbar, search for a button called Add Map. You can now draw a rectangle onto the paper, depending on how big you want it to be.

You can still change the zoom and area by clicking on the button Move Item Content. Now you can move the map by dragging or zoom with the mouse wheel. Be patient though, because QGIS always needs some time to reload the map. If you zoom in too far, you only see water.

The print layout is actually not for creating textures, but for creating... well print layouts. If you created a map for example, you can create different print layouts in various scales or with differing layers, legends, and so on. It is really a great tool. As soon as you input new data, the layout will just output that as well. We can adapt the output however as we like, so for example change the size and resolution.

What you can also do is to adapt the dimensions of the image, because sometimes you want the images to be square. If you right-click on the paper and select Page Properties you can adjust the dimensions of the paper to make it square. With the left-pane buttons Select/Move Item and Move Item Content you can again adapt the area within your square and make the map fit exactly on the print layout.

In 3D modelling we often use square textures. This isn't necessary for Cinema 4D per se, but for many other software. For example game engines like to use square textures. We therefore will also create square textures from the start, although Cinema 4D also allows rectangular textures.

Saving and exporting

Now it is time to save your project and give it a proper name. After you have done that, you can then Export as Image... in the print layout window. The software asks you about the resolution. Enter a number that feels comfortable to you, I chose 4000x4000 pixels. Hit Save. You have now sucessuflly exported the satellite image. Now, we also want the DEM in the same dimensions, right?

Change back to the QGIS main window and have a look at your Layers tab. You'll see the GeoTIFF as well as the Esri Imagery. Besides Esri Imagery, you can uncheck the little checkmark. When you switch back to your print layout window, you don't see a change. But at the top toolbar, you'll find a Refresh View button. If you click this, you'll see only the GeoTIFF.

Additional Info: If you think the greyscale could use more contrast, you can adjust this. Double-click on the gray band in the Layers tab in the main window. In the open dialogue, have a look at the Min and Max values beneath Color Gradient. If you adjust the max value (make it smaller) you might get more contrast. Just make sure nothing is pure white in the result. Check by hitting the Apply button. To see the change in the print layout, hit the Refresh button again.

You can now export the DEM again as before as an image and you have the same dimensions as the satellite image before. Make sure to use the same dimensions. Now, one last question might be, what size your patch of images actually is, because if you want to rebuild this in Cinema4D, you need to know the extensions in meters. If you right-click on the image in the print layout, you can select Item Properties. There you find the group Extends.

These numbers seem to be very random, but they aren't. They represent the coordinates of the sides of your print layout in meteres. There is a Y max and Y min. If you substract min from max, you got the height in meters. If you do the same with the X-values, you will get the width in meters:

Y max - Y min = Height in m

X max - X min = Width in m

Creating a 3D model in Cinema4D

Ok, now with the two images exported, we want to create a nice terrain model. In Cinema, we simply create a Plane object. In the Attributes Manager we can enter the calculated dimensions of the patch we exported and segment our Plane into 1000 by 1000 segments to get a fairly good resolution. We can create a new material in the Material-Manager and call it Satellite. We turn off Reflectance and open the satellite image in the Color tab under Texture. We can already drop this material onto our plane.

Now we need to calculate our height. For this, we create a Displacer Object and put hierarchically under the Plane. In the Object Properties tab we can enter the selected height under Height. The selected height is the max number shown in QGIS on the gray band in the Layers tab. In Cinema 4D in the Shading tab, we can open our DEM under Shader. There it is! Our own terrain model with which we can do whatever we want.

This page was last edited on 2024-04-11 14:15

Powered by Wiki|Docs

This page was last edited on 2024-04-11 14:15

Sebastian Hageneuer
CC BY-NC-SA 4.0 Deed

Powered by Wiki|Docs