Tutorial#
Let’s start using the Qgis2threejs plugin!
Install the plugin#
Open the Plugin Manager (Plugins > Manage and Install Plugins...) and
install the Qgis2threejs plugin.
Hint
Need help? See the 9.1. Installing and Managing Plugins section of the QGIS training manual.
Obtain elevation data#
If you already have raster DEM data, you can skip this step.
NASA has published elevation data generated from the Shuttle Radar Topography Mission. This digital topographic data is freely available. SRTM elevation data can be downloaded from the EARTHDATA site (user registration required).
Download a zip file that contains elevation data for your area of interest from EARTHDATA SEARCH.
The zip file includes a .hgt file, which can be read by GDAL.
Load DEM data#
Unzip the downloaded file, then drag and drop the .hgt file into the QGIS window.
CRS setting#
The horizontal unit of SRTM data is degrees, whereas the vertical unit is meters. For proper visualization, you should transform the DEM data to a projected CRS. QGIS can perform CRS transformation on the fly.
Change the current project CRS to a projected CRS.
Click the CRS status icon
in the bottom-right corner of the window to
open the project properties dialog, then select a suitable CRS for the DEM extent.
If you are unsure which CRS to use, select the Spherical Mercator projection
(EPSG:3857), which is used by many web maps.
Note
In the Spherical Mercator projection, feature sizes are horizontally enlarged except at the equator. At latitude 40° they are enlarged by about 1.3 times, and at 60°, about twice.
Layer styling#
Open the Layer properties dialog for the DEM layer and apply a color scheme.
Example: use the Singleband pseudocolor render type and an inverted BrBG color ramp.#
Open the Exporter#
Zoom to a portion of the DEM so that the map canvas is filled with the colorized DEM layer,
then click the plugin icon
in the Web toolbar to open the Qgis2threejs exporter.
The Layers panel shows the map layers in the current QGIS project that can be added to the 3D scene.
Layers are grouped by type. The DEM layer group includes single-band raster layers and a Flat Plane
(a flat surface at a specified altitude).
Multi-band raster layers and raster layers loaded using providers other than GDAL provider are not supported.
Additional flat planes can be added from the Scene - Add Layer menu.
A preview is displayed on the right. The scene is currently empty.
To add the DEM layer, click the checkbox on the left of the DEM layer in the DEM layer group.
A 3D terrain model with the map canvas image draped over it will appear in the preview.
Export the scene to Web#
Select File - Export to Web... to open this dialog.
Choose an output directory, enable the Enable the Viewer to Run Locally option, and click
the Export button.
Note
Most web browsers do not allow data files on the local file system to be loaded via Ajax.
When Enable the Viewer to Run Locally is enabled, the plugin embeds geometry and image data
into a JavaScript file.
Open the exported HTML file in a web browser to view the scene.
You can publish the exported 3D viewer by uploading the output folder to a web hosting service such as Netlify and GitHub Pages.
Note
Before publishing, make sure you comply with the data usage terms.
In conclusion#
This tutorial is now complete. You have learned that creating 3D visualizations with QGIS is easy. With high-quality data, you can create beautiful 3D scenes!
Tip
Next, try adding a background map layer to the canvas. You can do this easily with the QuickMapServices plugin. You can also add vector data to the scene. See Shape Types page for examples of available shape types, and Exporter for the detail.