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 pxTick Terrain Shading for light and shade on the slopes.
-
4. Tilt and turn
Shift + left-drag, or drag with the middle mouse buttonScroll to zoom. Zoom Full resets the camera.
-
5. Export
3D view › Export › Save as Image… or Export 3D SceneExport 3D Scene writes an OBJ model you can open in Blender.
Key takeaways
- 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.
- 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.
- 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.
- 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.
- 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.
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
- 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….
- Open Raster › Projections › Warp (Reproject)….
- 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.
- 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.
- 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.
- 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.
- 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.
- Make a hillshade with Raster › Analysis › Hillshade… (Z factor 1, azimuth 315°, vertical angle 40°).
- 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%.
Roads, rivers, labels, aerial imagery or an XYZ basemap all drape over the terrain too. Esri World Imagery over the DEM gives you a quick photo-realistic model. Keep the layer stack light, though: QGIS draws a texture for every terrain tile, so ten layers take ten times as long to appear.
Step 3: Set the DEM as the project terrain
- Open Project › Properties… and choose the Elevation page.
- Under Terrain, set Type to DEM (Raster Layer) and DEM layer to your reprojected DEM.
- 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.
- Click OK.
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.
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. |
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:
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 Qgis2threejs plugin, by Minoru Akagi, exports a DEM and map layers as an interactive three.js web page that anyone can spin round in a browser. Install it from Plugins › Manage and Install Plugins…. Use the built-in 3D view for pictures, models and animations, and Qgis2threejs when you want to share an interactive model online.
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:
- 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.
- It makes the hillshade, styles both layers and sets the DEM as the project terrain.
- It renders the three views above through a print layout 3D Map item.
- It saves
keswick-3d.qgz, ready to open in QGIS.
Run it from the OSGeo4W Shell, or on Windows with:
"C:\Program Files\QGIS 3.40.12\bin\python-qgis-ltr.bat" qgis_3d_dem.pyDEM: 1040 x 960 cells at 25 m, EPSG:27700, 63 m to 946 m (mean 357 m) in 1.4 slake-district-from-south-west: export result 0, 1889 x 1062 px, stable after 23 sderwentwater-borrowdale-from-north: export result 0, 1889 x 1062 px, stable after 20 sskiddaw-blencathra-from-south: export result 0, 1889 x 1062 px, stable after 22 sProject saved: output\keswick-3d.qgzExport 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.
Related tutorials
- XYZ tile URLs for QGIS: 27 free basemaps: imagery and maps to drape over your terrain
- Creating a 3D printed digital elevation model in QGIS
- From DEM to 3D-printable STL with Python and NumPy
- 3D terrain visualisation in Python with PyVista: Helvellyn from LiDAR, Sentinel-2 and a GPX route
- Terrain analysis in Python with rasterio: slope, aspect and hillshade from a DEM
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.
Data for this tutorial
- Copernicus DEM GLO-30 and GLO-90 · Free 30 m global DEM; free to use with the Copernicus credit
- LiDAR and elevation atlas: United Kingdom · 1 m and 2 m LiDAR and national DEMs for England, Scotland, Wales and Northern Ireland
- LiDAR and elevation atlas · Where to download free DEMs for every country
Licences and formats for each source are listed in the GIS data sources catalogue.
Need this done on your own data? TechnicalGIS takes on consulting projects like this one, from a single analysis to a pipeline your team can rerun.