Norway in 3D part I: from DEM to 3D surface

Wednesday, December 4th, 2013 | Data visualization, General

Earlier this year the Norwegian Mapping Authority released a bunch of free data, including Digital Elevation Model (DEM) files that describe the terrain of Norway in high detail.

I wanted to use this data to create a 3D model of Norway that I eventually could 3D print. This turned out to be a bit complicated, so I want to share some of my experiences in case anyone else wants to do something similar. So yes, this will be a bit technical.


Getting the DEM files

After registering and logging in to you are ready to download the files. But don’t think you get one file for the whole of Norway! First, you have to figure out which files to download (I used ‘Digital terrengmodell 10 m , UTM 33’), and then select and download 254 individual files one by one to get all the tiles you need.



Merging the tiles

So, now you have a lot of DEM files that you need to combine into one large file. I installed GDAL, which is an open source and powerful “translator library for raster geospatial data formats”. The library is used by various software packages, and can also be used with shell scripts. After quite a lot of googling and trial and error I managed to write a shell script that combined all the DEM files into one GeoTIFF file. The script:

#!/bin/bash -ps 100 100 -init 255 -o merged.tif *.dem

-ps 100 100 specifies the resolution for the output file. Higher number: smaller output file.
-init 255 specifies color range.
-o merged.tif specifies the output file.
*.dem uses all the DEM files in the current folder as input.

See full gdal_merge documentation for more.

GeoTIFF files are similar to regular TIFF images, but they store a lot of additional geospatial data. You may open the file in Photoshop, but you will probably just see some basic black and white contours.

Create heightmap

One of the simplest ways to create a landscape in 3D is to use a greyscale heightmap, and displace a surface according to the image. A heightmap is basically just an image in which color represents height, from low (black) to high (white). There are probably other more sophisticated ways of creating a 3D surface, but this is at least quite straightforward.

First, it is necessary to create a greyscale heightmap from the GeoTIFF file. This shell script did the trick:

gdal_translate -b 1 -scale -20 2500 -of PNG merged.tif heightmap.png

-b 1 select input band 1 (don’t even ask me).
-scale -20 2500 set height/color range from -20 m (black) to 2500 m (white).
-of PNG specify output file format.
merged.tif input filename.
heightmap.png output filename.

See full gdal_translate documentation

The result is a greyscale map that looks like this:


As you may see, parts of Sweeden have been included in this image. We can’t have that, of course, so I removed the Sweedish areas by applying a mask in Photoshop. Here is the final heightmap (click to see larger version on Flickr):

Norway heightmap

By the way, it looks even cooler with inverted colors, don’t you think? The fjords and the mountains look like veins in some kind of alien organism..

Norway inverted heightmap

Create 3D surface in Blender

A lot of 3D applications can create 3D surfaces from heightmaps. Since I am trying to use open source software as much as I can, I wanted to use Blender, and for this purpose it worked quite well. (The capabilities of Blender are impressive, but is unfortunately quite hard to use due to a range of usability issues, even though they did a major UI facelift a couple of years ago.)

Creating a 3D surface from a heightmap goes something like this:

  1. Create a plane
  2. Go to edit mode (Tab), and subdivide the plane (W). More subdivisions will give you more detail, but also a very heavy model.
  3. Go back to object mode, add new material to the plane
  4. Add new texture to the place, and select “Image or movie” as input. Load the heightmap image
  5. Add a Displacement modifier to the plane, using the texture as input. Adjust the strength to adjust how much the surface should be displaced

And voilà! You have Norway as a 3D surface. Add some light, and you get something like this:

Norway in 3D

You can probably see that I have exaggerated the height a lot in this particular model. Otherwise it would probably be hard to see any landscape at all.

Actually, when I look at it, I find this to be an interesting visualization in itself; by exaggerating the height, it is possible to get an impression of the topography of different areas of Norway in one picture, which otherwise would be impossible to achieve.

Wouldn’t it be cool to 3D print this? Oh yes, I’ll get back to that. And why I wish the earth was flat.

Tags: , , , , , , , , , ,

2 Comments to Norway in 3D part I: from DEM to 3D surface

Shannon White
March 23, 2017

This is awesome! Im impressed with the size of the 3d surface model that you have created. Currently I am working on modeling 500 acres of surface from a geotiff file supplied by an outside source and am processing the data using AutoCAD Civil 3D 2016. Much to my dismay the program runs incredibly slow and boggs down quite a bit when executing certain modeling commands. Would you have any advice on the kind of processing and memory that would be sufficient for a project of this type?
* I also have design items such as berms, roadway, and channels that are being added to this surface in seperate files and Data Shortcut into the final model. (Are you familiar with these terms?) I can provide a more thorough explanation if needed. Any advice would be greatly appreciated!

Jon Olav
March 24, 2017

Hi Shannon, unfortunately I don’t have any experience working with AutoCAD Civil 3D. However, if the geotiff file is very large you might get better performance by reducing the resolutions and size of the file. The tool I use for working with geotiff files is GDAL. Or, you could simply ask to get the file in a smaller size. Other than that I’m afraid I can’t help you, since I don’t have experience with your setup.

Leave a comment