QGIS magic — Old raster maps to 3D

What do you get when you combine old data with new data? Something cool and maybe even surprising. In this tutorial the old data are raster maps and new data are digital elevation models (DEM). Just by using QGIS you can easily turn old maps into 3D surfaces you can explore in your browser.

I got this idea already some time ago and also published online a few of the final results, but just now thought that it might write a short blog on how to do this. For some, this might also serve as a more general introduction to the awesome QGIS2threejs plugin or the Georeferencer.

This is what I’m talking about. I did this earlier.

Preparations

You basically only need QGIS (with a few plugins), an old raster map and a DEM raster. First get your QGIS ready by installing the necessary plugins. You can easily install the plugins through the Plugins dialog. What you need is:

  • Georeferencer (it actually comes with QGIS but you need to enable it in the dialog)
  • OpenLayers plugin (you can also use something else for this)
  • QGIS2threejs

Then you need to find the data. You might already have a raster map and a DEM from an area of your choice (skip to the last part if you do). But if you don’t that’s just fine too. As a general guideline, when I search for new data on a specific topic, my starting point quite often is the great Free GIS Data website (awesome name, btw). That’s how I also found the elevation models for this tutorial.

For the elevation model, there are several sources out there. Especially for the more detailed DEM’s you should look into local land survey websites. What is important when you select your data, is that you make sure that your DEM resolution somewhat matches the raster map you have selected. Check at least the following sources for DEM’s:

When I was searching for raster maps to georeference, it was a bit more tricky but luckily I got a few good tips on Twitter. So check out the following sites for cool old maps you can download:

These maps are not georeferenced. This means that when you put it into QGIS, the system doesn’t know the coordinates of the map and thus you can’t properly overlay other data (in our case the DEM) on top of it.

Why am I suggesting you to do it the hard way and not to select some raster file that someone has already georeferenced? I believe that you can get more interesting results this way and bring new raster maps to a format where you can actually use them also for other purposes in GIS software. I also think that just the idea of combining really old data with really modern data is just turns into something really intriguing.

For this tutorial I chose to use a map of the Korean peninsula from the CIA collection with the global 100 meter resolution DEM (first link) with also sea depth included.

Georeferencing the map

If your map is already georeferenced, you can of course skip this part.

From the Web dialog in your QGIS open OpenLayers plugin and from there select OpenStreetMap. You will use this OSM background map to select the georeferencing points to your raster map.

You can find the Georeferencer under Raster dialog. The map you will use, will be georeferenced to EPSG:3857 because it’s relatively simple with the OSM background map (although it’s not often the “optimal” projection). Please note that it might not work so well on some rasters which have a really local projection.

But now just add your map to the Georeferencer and start clicking!

In practice you now need to first click on your raster map in a specific point and then select From map canvas option in the dialog that opens and click on the same point in the OSM map on your QGIS canvas and then select Ok. For my map I chose to use a some of the cities as these points, but you can choose any points that you can easily detect on both maps. This way you don’t actually have to write any coordinates anywhere and leave less room for error.

It depends on your raster map how many reference points you need, but usually if the the original projection of the map is somewhat similar to your target projection, around four points should be enough.

Once you have entered enough reference points, you can press the Play button on top of the Georeferencer screen. As you are then asked for translation details, you can do it quite well with the default settings. Just change the compression mode to LZW so you don’t end up with a massive output and set the target SRS as EPSG:3857.

After you click Ok and run the translation, QGIS should add your map to canvas automatically and you should see the raster on top of the OpenStreetMap layer in the correct location.

Adding the third dimension to your map

This is the part where the map actually comes alive. You can remove the OSM layer from your QGIS project and add the elevation model you downloaded if you don’t already have it there.

Now open from Web dialog the QGIS2threejs plugin. The GUI you encounter at first look might seem a bit complicated at first look, but eventually it’s quite simple to build the 3D model with it.

First check that you have your elevation model file selected as the DEM model. As you probably now have your raster on the QGIS canvas on top of other layers, you can just keep the Display type option Map canvas image as it is by default. In the World settings you can find vertical exaggeration, where I had value 15. The optimal value depends fully on your data and what kind of results you want. I chose not to draw any sides on the map and selected the resolution to be 200% and background as black. You can also get very different results by changing the resampling level in your settings. I added a bit more detail from the default settings.

You can do quite well with the almost the default settings in QGIS2threejs

All in all you can make a 3D map with the great plugin almost by using the default settings, but depending on your goal you can adjust and test them quite freely. You can either output the 3D scene into a temporary file, or then export all of the necessary files (JavaScript & HTML files) to your disk and then share them somewhere for others to admire.

When you click run, in a few seconds you should be looking at something like this:

Final product! Some really interesting details in there and especially islands get a nice effect.

You can view the interactive version of my Korean peninsula map here. Hope you have nice time browsing through the datasets and bringing classic cartography to the 21st century!