3D mapping and bathymetry styling with QGIS 2.18

This is a guest blog from Liam Mason, a spatial analyst with Marine Scotland.  Some of his other data visualisations can be seen on his @marinemaps Twitter account or the Marine Scotland Maps portal maps.marine.gov.scot

[Edit: the tutorial was modified to use the GDAL-based DEM (Terrain Analysis) tools instead of Raster Terrain Analysis]

I love mapping bathymetric data in 3D. It’s almost magical, the ability to draw back the veil of the sea and reveal the mysterious landscapes below.

Yet, it’s remarkably simple to do using QGIS 2.8 or higher.

3D bathymetry map of inner Firth of Forth.
Bathymetry of inner Forth made using QGIS 2.8 and qgis2threejs

The Plugins

This tutorial uses one core and two additional plugins, which can be installed using Plugins > Manage and Install Plugins…

Screenshot of showing Plugins option in menu 

Firstly, ensure that GdalTools is installed and activated.

Screenshot of QGIS showing GDAL tools

Secondly, search for qgis2threejs, and install.

Screenshot of QGIS plugins showing qgis2threejs

Thirdly, search for and install quickmapservices which will give you access to a variety of basemaps.

Screenshot of QGIS plugins showing QuickMapServices

Both of the latter plugins are available in the Web menu.

Lastly, you can further expand the basemaps available in QuickMapServices via Web > QuickMapServices > Settings > More services > Get contributed pack

Screenshot of QuickMapServices 'get contributed pack' option

Other software

This tutorial involves picking colours from the basemap.

The Windows version of QGIS has an  integrated color picker tool, but for those of you using Mac OSX, Just Color Picker is an alternative (and free) colour picker tool available on the App store.

Just Color Picker on App store
Just Color Picker on App store

The data

We’ll need a digital elevation model (DEM) which contains both bathymetric and terrestrial elevation data otherwise either the land or sea will be flat.

This tutorial uses the GEBCO 2014 gridded data:


Although the data is quite coarse at 30 arcseconds resolution, it’s suitable for 3D mapping at country-wide scale.

On GEBCO website, holding down the Shift key, click the left mouse button and drag to select the area for download.Screenshot of GEBCO website showing selection map

Click to expand GEBCO_2014 Grid (30 arc-second interval). Tick INT16 GeoTIFF (data)

Screenshot of GEBCO website

Scroll down and click  Add data to basket.  When the text on this button greys out, click View basket.

On the next site, select Check out your request.

Screenshot of BODC website

If you don’t already have an account with BODC, you’ll need to register. Don’t worry though, it’s free and you won’t get spammed with emails.

Once registered, log in using your email and password.  If you don’t want to supply a reason or funding information, simply type any character eg a space and Login to proceed.

Screenshot of BODC website

Once logged in, you can Download the data.

Screenshot of BODC website

Alternatively if you only want to map the undersea terrain, EMODnet (http://www.emodnet-bathymetry.eu/data-products) is a fantastic source of open bathymetry data, but you may need to merge the rasters.

(For the Firth of Forth image, I combined a licensed bathymetry product from OceanWise, with Ordnance Survey’s Panorama terrestrial product)

The method

Loading and configuration

Firstly, use the Add raster button to load the GEBCO DEM.Add Raster data button

Now we’ll drape a basemap imagery layer via QuickMapServices > ArcGIS Online > ArcGIS Online Imagery (options may vary depending on version of Contributed Pack)

[I had to use ESRI > ESRI Satellite. Ed.]

Screenshot of ArcGIS online imagery in QuickMapServices menu

Set the Project Properties to EPSG:3857. (Pseudo/Spherical/Web Mercator, whatever you want to call it!)

Screenshot of QGIS project properties in menu

Screenshot of project properties showing EPSG 3857 selected

This changes the project’s units to metres, which makes it easier to use the 3D plugin.

EPSG:3857 is the native projection for the basemap.  Other metre-based projections can be used to reduce distortion, but  other projections  may reduce performance if transforming / projecting on-the-fly.

Creating the 3D viewer

Zoom and pan to the area of interest.

Screenshot of ESRI world imagery

Load the qgis2threejs 3D plugin via Web > Qgis2threejs > Qgis2threejs

Screenshot of qgis2threejs in menu

Change the template file to 3Dviewer.html (this reduces some of the tools in the resulting interactive map)

Screenshot of template file in qgis2threejs

In World settings, enter an appropriate vertical exaggeration.  In this tutorial, we want to exaggerate large undersea features, so we’ll use 40, but normally we’d use a smaller value.

Screenshot of vertical exaggeration settings in qgis2threejs

(Note: if the project’s horizontal units are degrees, we’d need to use very small decimal values. That’s why we changed the project’s properties)

In DEM settings, ensure the GEBCO data is selected as the DEM Layer.

For the highest resolution output, slide the Resampling slider to the right and set the Resolution to 400% (these settings may need to adjusted depending on your computer’s performance).

Optionally, untick Build sides.

Screenshot of qgis2threejs DEM settings

Finally, set an Output HTML file path and Run to start

Screenshot of qgis2threejs file path and run options

It’ll take a moment to process, but the output HTML should load in your browser automatically. (In Internet Explorer 11, you may need to okay an error pop-up)

3D model of North Atlantic

Voila! You have an interactive 3D model of the north Atlantic. Neat, huh?

Improving the bathymetry style (colours)

The imagery basemap in this tutorial includes bathymetric shading at smaller scales.  We have more control if we create our own custom bathymetry style though. (The same tricks can be applied with for 2D mapping too)

Firstly, add another copy of the DEM using Add raster button, ensuring it’s positioned above the basemap in the table of contents.Add raster button

Right-click the copy layer and select Properties

Screenshot of layer properties in menu

In Style, select Singleband pseudocolor  as Render Type.

Set the Max to 0 and the Min to approximately the deepest point in the visible extent. We’ll use -2000 as an example.

Screenshot of raster style properties

Use the Add values manually button, double click on the value field for the resulting entry and enter -20.

Using a colour dropper tool, change the three colours to the lightest sea colour on the basemap. (If using high resolution aerial imagery, try to avoid sandy beaches)

Screenshot of raster classification values

Screenshot of colour options

Now adjust the colour for the deepest value (-2000 in example) by moving the V slider (value) to the left which will darken the colour. 

Screenshot of colour options

For the shallowest depth (0), adjust the opacity to 0%. Values shallower than 20m now fade to transparent.

Screenshot of colour options

We now have a bathymetry colour scheme that works stylistically with the basemap.

We can experiment by changing the depth values. The shallower depth works best between -10 and -30.  Changing the deeper value from -2000 to -1000 for example, the darker colour moves shallower.

Screenshot of ESRI World Imagery with custom bathymetry colours (no shading or texture)

Improving the bathymetry style (shading and texture)

Next we’ll improve the shading and texture.

Select Raster > Analysis > DEM (Terrain Models)…

Screenshot showing DEM tools

Select DEM as Input file

Set an output file.

Ensure mode is Hillshade.

The example data stores height data in metres but uses degrees as horizontal units, so the Scale should be 111120.  (See gdaldem guidance )

Tick Load into canvas when finished

Run tool using OK

Screenshot of DEM tools

When the hillshade layer loads, open the properties.  Experiment with the Style settings for different effects.

I tend to pick Soft light for blending mode, with increased brightness and increased contrast.

The default min and max values are rarely suitable, I used 125 and 255 respectively.  (HT to Ireland QGIS User Group)  

Screenshot of raster layer properties

The final improvement is to add a slope analysis via Raster > Analysis > DEM (Terrain Models)…

Screenshot showing DEM tools

Similar prodecure to hillshade, but select Slope for Mode.

Again, Scale should be 111120 for tutorial data. Same guidance applies for slope as per hillshade

Screenshot of DEM tools

Once loaded, adjust the Style Properties of the slope layer so Color gradient is White to black.

Like the hillshade analysis, experiment with Min/Max, blending modes, brightness, contrast, and transparency.

Screenshot of properties

Screenshot of transparency

The settings  in screentshots above are used in the example below.

ESRI World Imagery with custom bathymetry applied

We now have a custom bathymetry style with improved shading and texture. 

Finally, repeat the QGIS2threejs steps to create a 3D model using our custom bathymetric style.

3D model of North Atlantic using ESRI World Imagery and custom bathymetry

Ta-da!  Now have some fun and experiment with different basemaps!  

3D model of North Atlantic using OSM Mapnik and custom bathymetry
3D map using OSM Mapnik render



Creating 3D choropleth or prism map in QGIS 2.18

Contains OS data © Crown copyright and database right (2017)

It is possible to very quickly render any choropleth map you make in QGIS in 3D using the Qgis2threejs plugin. Essentially the plugin allows you to turn a numerical attribute as a “height” for your data. The results from the plugin are outputted as an html page which can be easily shared in a folder or placed on the web for people to view.

The Data


The Electoral Commission website contains a lot of data that can be used for making choropleth maps of all kinds. For this post I have used the EU Referendum results .CSV file:



If you are making choropleth maps of Great Britain then the best place to start with when looking for boundaries is the Ordnance Survey’s Boundary-Line Data:


The Method

I have used the data above to create a shapefile of London Boroughs with attributes that include the total number of votes, the number of votes to remain in the EU, and the number of votes to leave from the 2016 EU referendum. This was done using a table join based on the Area_Code from the result data CSV and the CODE in the Boundary-Line data for the London Boroughs.

The new file is called London Borough EU Ref and you can download a copy here: LondonBoroughEURef.zip

I have also added in a Stamen Toner (Retina) basemap using the method described here: Adding web Basemaps in QGIS 2.18

Adding Qgis2threejs

To start creating your Prism Map you will need to add in the Qgis2threejs plugin using the Manage and Install Plugins interface:

Once installed you access the plugin via the Web menu in the top bar:

Setting up the data

Before we can get to work creating a 3D map we need to set up the data in the 2D map. In this example we are going to show the number of votes in the referendum for the London Boroughs as the 3D height, however we have the option to use the colour of the boroughs to show a second attribute. It is actually very useful to make the polygons different colours as it is then easier to interpret the map.

  1. Right-click on the London Borough EU Ref layer and select Open Attribute Table
  2. In the attribute table window click on the Field Calculator Button:

In the field calculator window we need to do the following:

  1. Check Create a new field
  2. Set the Output field name to be %_Remain
  3. Set the Output field type to be Decimal number (real)
  4. the Output field length can stay at 10 but set the Precision to be 2
  5. In the expression window create the following statement:

    ( “Vote_Remai” / “votes” ) * 100

  6. Click OK

You will now see the new column in the attribute table but you still need to save your change and turn off editing mode.

  1. Click on the Save Edits button:
  2. Click on the Edit Mode off button:

Styling the data

We can now apply a graduated colour scheme based on this new column.

  1. Press F7 on the keyboard to open the Layer Styling dock on the right side of the map
  2. Make sure you are editing the London Borough EU Ref layer at the top
  3. Change the Single Symbol option to Graduated
  4. Change the Column to %_Remain
  5. Change the Color ramp to RdBu (Red to Blue through White)
  6. Check the Invert option (this makes leave favouring areas blue and remain red, the standard colours adopted for the referendum results)
  7. Change the number of Classes to 7
  8. Set the Mode to be Equal Interval
  9. Click Classify
  10. Manually adjust the Values to 10% bands, starting at 20% votes to remain through to 80% votes to remain. Make sure that white represents 50%. If you double click in the the value column of the table in the Layer Styling dock it will open a window where you can edit each entry:
  11. Finally change the Layer Blending Mode to Multiply so that you can see the details of the base map through the colours with no nasty washed out effect you get with transparency. This effect works particularly well on the black and white basemap.

The resulting map is shown below, with the areas of the lowest votes to remain as the darkest blue, white represents 50%, and the darkest red in the areas with the most votes to remain:

Map data © OpenStreetMap contributors, Contains OS data © Crown copyright and database right (2017)

The Prism maps produced by Qgis2threejs show a flat plane with extruded blocks extending upwards. The flat plane will appear as it is in the map window. It can be good to have a little transparency on the extruded blocks and so you don’t want the colours you have just set interfering with this. However it can be useful to see the boundaries you are extruding upwards. To show these:

  • Right-click on the London Borough layer
  • Select Duplicate

You will end up with a copy of the layer called London Borough EU Ref copy

Style the new layer to show just the outlines:

  1. Set the style to be Single symbol, Simple fill
  2. Se the Fill to be Tranparent
  3. Set the Outline to be Black
  4. Increase the Outline width to 0.7 so it will show up a bit more clearly
Contains OS data © Crown copyright and database right (2017)

Preparing the map for conversion to 3D

You should now turn off the coloured London Boroughs layer and use the Zoom to Layer Extent to set up the map as show below:

Map data © OpenStreetMap contributors, Contains OS data © Crown copyright and database right (2017)

Setting up Qgis2threejs

You can now open the Qgis2threejs plugin from the Web menu:

There are a a whole raft of options to look at with this plugin as it can be used not only for Prism Maps but for accurate 3D landscape models too.

We’ll run through the changes needed to make a Prism Map, the rest of the parameters can be left as the default settings.

Well start at the top of the menu on the left:


The only thing to change here is the Background colour. The default is sky which works well for landscapes but I have set this to black which works better for the colours of this map.


This can be left as the defaults.


The only thing to change here is to scroll down and switch off the Build Sides option.

Additional DEM

This can be left as the defaults.


  1. First we need to set which polygon layer we are going to extrude up, check the box next to London Borough EU Votes.
  2. The main thing to change here is to set the Height value to be Votes
  3. multiplier to be 0.1. The values are set in map units but as there were so many votes this makes the Prisms too high. if you are dealing with low values over larger areas then you will need a high multiplier to see any effect.

The Results

So now you are ready to Run the plugin, I tend to leave the location to be the temp folder while I play around with the colours, zoom levels and height multipliers. Once you are happy then you can set your location and the plugin will create a folder there with all the information needed to create the html page:

Here is the result:

Map data © OpenStreetMap contributors, Contains OS data © Crown copyright and database right (2017)

Note that the website can take a while to generate and the more complicated the geometries of the polygons the longer it takes to render. Microsoft Edge and Internet Explorer can take a bit longer to display than FireFox and Chrome, but once loaded all browsers tend to run well.

One thing I have found is that the models look better when the polygons are simple. American States, which have a lot of straight lines, tend to work better than UK counties or constituencies. Here is the same data for London, but put into HexBins. I’ve added labels to help identify which hexagon represents which borough.

It is possible to edit the CSS to change things like the font and text size for the labels.

Map data © OpenStreetMap contributors

Here is a link to the actual model created:

London Remain Votes Prism Map