The QGIS2threejs plugin is an excellent, lightweight utility for the visualisation of surface data such as DEM. But what if your workflow requires the interpretation and visualisation of geophysical data? Fortunately there are a few simple tricks you can perform in QGIS and with this plugin to easily visualise other gridded data types. You can also add legends to create publication-quality 3D images.
Imaging geophysical data
First you’ll need to load your geophysical data by adding them as rasters. Spend a bit of time imaging your data in the Layer Styling panel. One really good way to visualise your geophysical data is by making a colourdrape image:
- Duplicate your geophysics raster
- Apply a hillshade to the lowest in the layer menu (if this doesn’t shade very well it is because your data is dissimilar from typical elevation – just fiddle the Z-scale until you are happy)
- Apply a singleband pseudocolour stretch to the top layer in the Layer Styling panel
- Then scroll down in the Layer Styling panel to the Layer Rendering menu and change it from “normal” to something you are happy with (overlay and burn work quite well but you will usually need to make adjustments to the contrast and brightness)
Depending on the size of your data and the area you want to focus on you may need to clip extent to canvas on your top layer so that there is a good stretch through your colourtable. This is important for close-ups of your data.
When you “clip extent to canvas” the full colourtable is stretched across the area of interest providing a better contrast between features and anomalies. Use the slider to compare.
When you are happy with the layer styling of your geophysical data and ready to export the 3D model try the following:
- Install the QGIS2threejs plugin
- Ensure that the geophysical image you wish to have in your model is displayed in the map window with the appropriate styling
- Start the plugin from the menu Web>QGIS2threejs>QGIS2threejs or by clicking the icon
- Adjust the vertical exaggeration beneath Scale and Shift in the World tab. As the QGIS2threejs plugin assumes the model space is always built with respect to a DEM (elevation model in metres) any raster with values significantly different from typical Earth surface values will cause the 3D model to be non-useful. The amount of vertical exaggeration will depend on your data and could range from 0.1 to 200 for a useful model. DOn’t expect to get it right the first time and if you need a second crack the plugin thankfully saves the last-used parameters
- Within the DEM menu select the geophysical raster that you wish to view in 3D and make sure that under Display Type you select Map Canvas Image so that all your hard work creating a decent image will be exported to the 3D model
- Press Run!
There are a number of other things the QGIS2threejs plugin can do, but that’s really all there is to making a quick 3D visualisation. If you want to know how to create a custom legend that can be viewed in the 3D model read on…
QGIS2threejs plugin pop-up window to control the parameters of your 3D model export
Creating a legend image in QGIS Print Composer
Legends are very important as they quantify your model. The QGIS2threejs plugin doesn’t have this functionality built in yet. But if you want to add a legend to your 3D model try the following workaround:
- Open the QGIS print composer
- Add the map you wish to model to the print composer by clicking
The Print Composer window showing the map area with imaged geophysical data and a default legend for the raster image
- Add a Legend to the print composer by clicking . If you are happy with the discrete intervals and formatting of the defined by default then just check the legend title and units. These can be changed by selecting the Legend item in the Item Properties panel and clicking . If you are going to be changing any legend properties ensure that auto-update is switched off.
Alternatively you can create your own continuous legend using a rectangle with a gradient fill:
- Add a shape to the composer and select “Add Rectangle”.
- Decide on the size and ratio of your shape
- Select the rectangle to change its properties in the Item Properties panel
- Change fill style to Gradient Fill
- Choose the colour ramp for your legend that matches the ramp you have used to image your geophysical data. If you have used a predefined colour ramp for your geophysical imaging within the map window then choose the same colour ramp for your gradient fill. If not then you will need to customise your own ramp by clicking on the Edit button
- Add stops to your gradient colour ramp using the excellent range of colour palettes
Object style properties window (left) and gradient colour ramp editing window (right)
To make your colours accurate go back to the QGIS map window and select Properties for your raster layer. In the style menu you will be able to copy the HTML values (e.g. #31007e) for each colour then use these as stops in your gradient fill. Alternatively you can use the colour picker , just make sure that the layers legend is visible when you open the gradient ramp editor.
Gradient colour ramp editing window showing a number of stops, each correponding to the discrete colours in the default legend selected using the colour picker tool
Final colour gradient legend with title, units and simplified scale
When you are happy with your legend you will need to export it as an image to be incorporated into the 3D model:
- Export the image by going to Composer>Export as image
- Choose your desired resolution and select your file path, filename and file type
- Before clicking Save make sure you select the Crop to content box as this will save the hassle of cropping your legend later
- Click Save
Options for exporting your legend as an image from the Print Composer
Add the legend to the QGIS2threejs model
This is the tricky part and will require a bit of testing before you get it how you want the first time:
- Track down the folder with all the files that were exported from QGIS2threejs (Or alternatively just export it your model again making sure you check the HTML file path at the bottom of the Plugin pop-up window
- Copy your legend image file into the 3D model folder that you defined when exporting from QGIS2threejs
QGIS2threejs plugin pop-up window again – showing the HTML file output path
- Open the .html file in text editing software (something like Wordpad works well)
- Within the <HEAD> add the position, size and source for your legend. What is shown below works quite well. But make sure that you copy the legend image into the same directory as the other QGIS2threejs files!
The head of the HTML file exported by QGIS2threejs for your model. Highlighted text shows simple format for adding your legend to the 3D model space
- Save your file from within the text editor (you may need to save it as a .txt but you can manually change the file extension back to .html after)
- Open the html file for your model and be amazed (or disappointed). If the latter then go back into the .html file and adjust the image size and position
To make this look really good try matching the background of the legend with the 3D viewer background. You can do this in by matching the Hex code in both the .html file and in the Print Composer background