QGIS 3D map view: turn a DEM into 3D terrain

Turn a digital elevation model into 3D terrain in QGIS without plugins: reproject the DEM, drape a hillshaded colour ramp over it, set it as the project terrain, open a 3D map view, exaggerate the relief and export images, OBJ models and animations. Worked example: Keswick, Skiddaw and Helvellyn from the free Copernicus DEM.

Level
Beginner
Tested with
Python 3.12
Source code
Download scripts

DEM to 3D in QGIS, in five clicks

Your DEM must be in a projected CRS in metres, such as British National Grid or a UTM zone. Then:

  • 1. Set the terrain

    Project › Properties › Elevation › Terrain › Type: DEM (Raster Layer)

    Pick your DEM in the DEM layer box and click OK.

  • 2. Open the 3D view

    View › 3D Map Views › New 3D Map View (Ctrl+Alt+M)

    It opens with the same extent as your 2D map.

  • 3. Exaggerate the relief

    3D view › Options › Configure… › Terrain › Vertical scale 1.5, Tile resolution 64 px

    Tick Terrain Shading for light and shade on the slopes.

  • 4. Tilt and turn

    Shift + left-drag, or drag with the middle mouse button

    Scroll to zoom. Zoom Full resets the camera.

  • 5. Export

    3D view › Export › Save as Image… or Export 3D Scene

    Export 3D Scene writes an OBJ model you can open in Blender.

Key takeaways

  1. QGIS can show any DEM in 3D with no plugins. Set the DEM as the project terrain under Project › Properties › Elevation, then open View › 3D Map Views › New 3D Map View.
  2. Reproject the DEM to a projected CRS in metres first. Our Copernicus tiles came in latitude and longitude; we warped them to British National Grid at 25 m.
  3. The 3D view drapes your 2D map over the terrain, so style the DEM first. A colour ramp with a hillshade set to Multiply on top looks far better than greyscale.
  4. A vertical scale of 1.5 makes hills read clearly without turning them into spikes. A tile resolution of 64 px and a skirt height of 60 removed the blocky edges and hairline cracks we saw at the defaults.
  5. Save as Image gives a screen-sized picture; Export 3D Scene writes an OBJ model; a 3D Map item in a print layout gives a high-resolution image at a camera angle you can set exactly.

Before you start

  • QGIS 3.34 or later (tested with QGIS 3.40.12 LTR)
  • A DEM, or an internet connection to cut one from the free Copernicus DEM
  • For the optional script: the Python that ships with QGIS

Short answer: QGIS turns a DEM into 3D terrain with no plugins. Make sure the DEM is in a projected CRS in metres, set it as the terrain under Project › Properties › Elevation, then choose View › 3D Map Views › New 3D Map View. Raise the Vertical scale to about 1.5 in the view’s configuration, tilt with Shift + drag, and export with Save as Image or Export 3D Scene.

This tutorial builds a 3D model of the northern Lake District around Keswick, from the free Copernicus 30 m DEM: Skiddaw and Blencathra to the north, Derwentwater and Borrowdale in the middle, and the Helvellyn ridge above Thirlmere to the east. Every step was run in QGIS 3.40.12 LTR, and every picture on this page came out of that run. If you’d rather script it, the same workflow is in qgis_3d_dem.py.

A QGIS 3D map view of Skiddaw and Blencathra seen from the south, with green valley floors, brown fell sides and pale summits, built from the Copernicus 30 m DEM.
Skiddaw (left) and Blencathra (right) from above Keswick, looking north. QGIS 3.40.12 3D map view, vertical scale 1.5. Copernicus DEM GLO-30: © DLR e.V. 2010-2014 and © Airbus Defence and Space GmbH 2014-2018, provided under COPERNICUS by the European Union and ESA.

What you need

  • QGIS 3.34 or later. The 3D map view is built in; you don’t need a plugin.
  • A DEM. Any single-band elevation raster works: a national LiDAR DTM, SRTM, or the Copernicus DEM. Our LiDAR and elevation atlas lists the free sources for every country; for Britain, the United Kingdom page covers the 1 m and 2 m LiDAR from England, Scotland, Wales and Northern Ireland.
  • A projected CRS in metres. The 3D view measures distances and heights in the same units. A DEM in latitude and longitude has heights in metres but positions in degrees, so the terrain comes out squashed into a thin sliver or stretched into needles. Reproject first.

We used two 1° tiles of the Copernicus DEM GLO-30, N54 W004 and N54 W003, because our window straddles 3° west. The Copernicus DEM is free for any use, including commercial, as long as you show the credit in the captions on this page.

Step 1: Reproject the DEM to metres

  1. Add your DEM tile or tiles to QGIS. If you have more than one, merge them with Raster › Miscellaneous › Merge…, or build a virtual raster with Raster › Miscellaneous › Build Virtual Raster….
  2. Open Raster › Projections › Warp (Reproject)….
  3. Set Target CRS to a projected CRS for your area. We used EPSG:27700 – British National Grid. Elsewhere, pick the UTM zone your area falls in.
  4. Set Resampling method to Cubic so the reprojected surface stays smooth, and Output file resolution to 25. Copernicus cells are about 30 m by 18 m at this latitude, so 25 m keeps the detail without inventing any.
  5. Under Advanced Parameters, use Georeferenced extents to clip to your area. Ours was 318000, 344000, 510000, 534000 [EPSG:27700], a window 26 km wide and 24 km tall.
  6. Click Run.

Our result was 1,040 by 960 cells. Heights ran from 63 m by Bassenthwaite Lake to 946 m on Helvellyn. The real summit is 950 m; a 25 m cell averages the ground across the top, so it sits a few metres lower. Skiddaw’s highest cell is 928 m and Keswick sits at 91 m.

Step 2: Style the DEM, because the 3D view drapes your 2D map

The 3D view takes its shape from the terrain and its colours from your 2D map. A plain greyscale DEM gives you grey 3D terrain, so spend two minutes on the style first.

  1. Right-click the DEM › Properties › Symbology. Choose Singleband pseudocolor, set Min and Max to your height range, and pick a colour ramp. We made a simple hypsometric ramp: green on the valley floors, tan and brown on the fell sides, pale grey on the tops.
  2. Make a hillshade with Raster › Analysis › Hillshade… (Z factor 1, azimuth 315°, vertical angle 40°).
  3. Put the hillshade above the DEM in the Layers panel. In its Symbology, open Layer Rendering, set Blending mode to Multiply and Opacity to about 55%.
QGIS 3.40 with the Layers panel listing Hillshade above Copernicus GLO-30 DEM (25 m), and the map showing the northern Lake District in green, tan and brown with hillshading: Bassenthwaite and Derwentwater in the valley on the left, Skiddaw and Blencathra at the top and the Helvellyn ridge at the bottom right.
The 2D map that the 3D view will drape over the terrain: the DEM with a hypsometric colour ramp and a hillshade multiplied on top, in British National Grid.

Step 3: Set the DEM as the project terrain

  1. Open Project › Properties… and choose the Elevation page.
  2. Under Terrain, set Type to DEM (Raster Layer) and DEM layer to your reprojected DEM.
  3. Leave Vertical scale at 1.00 and Offset at 0.00 here; it’s easier to change them in the 3D view, where you can see the effect.
  4. Click OK.
The QGIS Project Properties dialogue on the Elevation page, with the Terrain section set to Type DEM (Raster Layer), DEM layer Copernicus GLO-30 DEM (25 m), Vertical scale 1.00 and Offset 0.00.
Project › Properties › Elevation in QGIS 3.40. Older releases call this page Terrain; the settings are the same.

Every 3D map view in the project starts from this terrain. Saving the project saves it too, so next time you can go straight to Step 4.

Step 4: Open a 3D map view

Choose View › 3D Map Views › New 3D Map View, or press Ctrl+Alt+M. A new panel opens, looking straight down on the same extent as your 2D map. Drag it out and maximise it if you want more room; the button at the right-hand end of its toolbar docks it back.

The QGIS View menu open with 3D Map Views highlighted and its submenu showing New 3D Map View (Ctrl+Alt+M) and Manage 3D Map Views.
View › 3D Map Views › New 3D Map View. Manage 3D Map Views reopens, renames or duplicates views you've saved in the project.

Step 5: Exaggerate the relief and smooth the terrain

At true scale, even the Lake District looks flatter on screen than it does from a fellside. Open the view’s Options menu (the spanner icon) › Configure… and choose the Terrain page:

Setting Default We used Why
Vertical scale 1.00 1.50 Makes the fells read clearly without turning them into spikes. Use 2–3 for gentle landscapes; keep 1.0 for any measurement or a “true scale” view.
Tile resolution 16 px 64 px At 16 px the ridges looked blocky; 64 px followed the 25 m DEM closely. Try 128 px on a powerful graphics card.
Skirt height 10 map units 60 map units At 10 we saw thin white cracks between tiles on steep slopes; 60 hid them.
Terrain Shading Off On Lights the slopes from the scene’s light, so the shape still shows where the hillshade texture is faint.
The QGIS 3D Configuration dialogue on the Terrain page: Type DEM (Raster Layer), Elevation Copernicus GLO-30 DEM (25 m), Vertical scale 1.50, Tile resolution 64 px, Skirt height 60.0 map units, Offset 0.00, and Terrain Shading ticked.
The 3D Configuration dialogue with the settings from the table. Lights, Effects and Camera & Skybox are on the pages to the left.

Click OK. The terrain reloads in a few seconds, sharp tiles near the camera first and coarser ones in the distance.

Step 6: Move around the 3D view

To Mouse Keyboard
Tilt the terrain Shift + left-drag up or down, or middle-drag Shift + Up/Down
Turn the terrain Shift + left-drag left or right, or middle-drag Shift + Left/Right
Move the camera Left-drag (with Camera Control on) Arrow keys
Zoom Scroll wheel (Ctrl + scroll for small steps), or right-drag
Raise or lower the camera Page Up / Page Down
Look around from where you are Ctrl + left-drag Ctrl + arrow keys
Start again Zoom Full on the toolbar

The Toggle On-Screen Navigation button adds a compass and arrows, which are handy on a trackpad. The Camera menu can synchronise the 2D and 3D views, so the 3D camera follows as you pan the 2D map, or the 2D map follows the 3D camera.

These three views were all made from the same project, with different camera positions:

A wide 3D view of the northern Lake District from the south-west: the green vale of Keswick and Derwentwater in the foreground, Skiddaw and Blencathra behind, and the Helvellyn ridge and Thirlmere valley on the right.
The whole 26 by 24 km model from the south-west. Derwentwater and the vale of Keswick are the green floor in the foreground; Thirlmere's valley runs up the right beneath the Helvellyn ridge.
A 3D view from the north looking south down Derwentwater into Borrowdale, with the fells of Newlands on the right and the Helvellyn range in the distance on the left.
Looking south from above Keswick, down Derwentwater into Borrowdale. The flat green floor is the lake and its valley: the DEM has no water, so lakes show as level ground.

Step 7: Export the 3D view

Everything is under the Export button on the 3D view’s toolbar:

  • Save as Image… saves exactly what’s on screen, at the panel’s size. Make the panel bigger before you save for a bigger picture.
  • Export 3D Scene writes the terrain, with its texture, as an OBJ model you can open in Blender, MeshLab or a web viewer. Set Terrain resolution and Terrain texture resolution higher than the defaults for a detailed model.
  • Animations (the play button) records a fly-through. Add keyframes at different camera positions, preview it, then Export Animation Frames and join the frames into a video with any video editor or ffmpeg.

For a high-resolution picture at an exact angle, use a print layout instead. Add a 3D Map item with Add Item › 3D Map, click Copy Settings from a 3D View… in its properties, then set the camera’s centre, distance, pitch and heading by number. That’s how we made the images on this page: 320 by 180 mm at 150 dpi.

If you want a 3D print rather than a picture, see Creating a 3D printed digital elevation model in QGIS or the Python route in From DEM to 3D-printable STL.

The same workflow as a PyQGIS script

qgis_3d_dem.py runs every step above with the Python that comes with QGIS, with nothing to install:

  1. It cuts the window from the two Copernicus tiles straight from the AWS Open Data bucket (without downloading the whole tiles) and warps it to British National Grid at 25 m.
  2. It makes the hillshade, styles both layers and sets the DEM as the project terrain.
  3. It renders the three views above through a print layout 3D Map item.
  4. It saves keswick-3d.qgz, ready to open in QGIS.

Run it from the OSGeo4W Shell, or on Windows with:

Terminal window
"C:\Program Files\QGIS 3.40.12\bin\python-qgis-ltr.bat" qgis_3d_dem.py
Output
DEM: 1040 x 960 cells at 25 m, EPSG:27700, 63 m to 946 m (mean 357 m) in 1.4 s
lake-district-from-south-west: export result 0, 1889 x 1062 px, stable after 23 s
derwentwater-borrowdale-from-north: export result 0, 1889 x 1062 px, stable after 20 s
skiddaw-blencathra-from-south: export result 0, 1889 x 1062 px, stable after 22 s
Project saved: output\keswick-3d.qgz

Export result 0 means success. The 3D engine loads terrain tiles in the background, so the script keeps exporting each view until three exports in a row come out identical; that took about 20 seconds per view.

Troubleshooting

  • The terrain is flat. Check that Project › Properties › Elevation has your DEM selected, not Flat terrain, and that the DEM’s heights are in metres. If the land rises a little but looks pancake-flat, raise the vertical scale.
  • The terrain is a thin sliver or a field of spikes. The DEM or the project is in latitude and longitude. Reproject the DEM to a projected CRS (Step 1) and set the project CRS to match, in the bottom-right corner of the QGIS window.
  • Part of the terrain is missing. Your DEM has no data there. Ours did at first: one Copernicus tile stops at exactly 3° west, which cut Helvellyn in half until we merged the neighbouring tile.
  • Thin white or black lines between tiles. Raise Skirt height in the 3D configuration.
  • The terrain looks blocky. Raise Tile resolution. 64 px suits a 25–30 m DEM; LiDAR at 1–2 m benefits from 128 px.
  • The 3D view is black or empty. Click Zoom Full. If it’s still empty, update your graphics driver: the 3D view needs OpenGL 3.3 or later.

Frequently asked questions

How do I convert a DEM to 3D in QGIS?

Set the DEM as the project terrain under Project › Properties › Elevation › Terrain (Type: DEM (Raster Layer)), then open View › 3D Map Views › New 3D Map View. No plugin is needed. Reproject the DEM to a CRS in metres first.

Do I need a plugin to see 3D terrain in QGIS?

No. The 3D map view has been built into QGIS since version 3.0. Plugins such as Qgis2threejs add extras, such as exporting an interactive web page, but you don’t need them to view or export 3D terrain.

How do I exaggerate the height in a QGIS 3D view?

Open the 3D view’s Options › Configure…, choose Terrain and raise Vertical scale. 1.5 suits mountains; gentle lowland terrain often needs 2 or 3.

Why is my QGIS 3D terrain flat?

Usually because the terrain type is still Flat terrain in the project’s Elevation settings, or the DEM is in degrees rather than metres. Set the DEM as the terrain and reproject it to a projected CRS.

Can I export a QGIS 3D view as a 3D model?

Yes. Export › Export 3D Scene in the 3D view writes an OBJ file with the terrain mesh and its texture, which opens in Blender and most 3D software. For a printable STL, see our DEM to STL tutorial.

Where can I download a free DEM?

The Copernicus DEM GLO-30 covers the whole world at about 30 m and is free for any use. Many countries publish finer LiDAR DEMs; our LiDAR and elevation atlas lists them country by country.

Key terms

DEM
Digital elevation model: a raster where each cell holds a ground height, here in metres above sea level.
Project terrain
The elevation surface that every 3D map view in a QGIS project uses. Set it under Project › Properties › Elevation.
Vertical scale
A multiplier on heights in the 3D view. 1.0 is true scale; 1.5 makes every hill half as tall again.
Tile resolution
How many elevation samples QGIS uses across each terrain tile. Higher values give smoother, more detailed terrain and take more graphics memory.
Skirt height
Short vertical walls QGIS adds around each terrain tile to hide thin cracks where neighbouring tiles meet.
QGIS 3.40 with the Browser panel listing XYZ Tiles connections from basemap.at to IGN Plan IGN v2, and the map showing Esri World Imagery of Keswick and Derwentwater in the Lake District with Esri road and place-name overlays on top.

Tutorial QGIS

XYZ tile URLs for QGIS: 27 free basemaps, checked and ready to load

A checked list of XYZ tile URLs for QGIS: OpenStreetMap styles, Esri imagery and overlays, Sentinel-2 cloudless, and national basemaps for the US, the Netherlands, France, Austria, Switzerland and Germany. Each has its max zoom, attribution and terms, plus a connections file that adds all 27 at once and an open satellite hybrid.

Beginner 13 min read