We presented a workshop on Mesh layer in QGIS during FOSS4G in Bucharest. Below is step-by-step guide for those who’d like to know more about mesh layers in QGIS.
Data for this tutorial can be found here.
In this tutorial, we are going to work with a mesh layer in QGIS. Throughout this tutorial you will learn to:
Load a mesh layer
Working with time
Creating time series/cross section plots
For the purpose of this tutorial, we are going to use the ERA5 dataset from ECMWF:
(the data in the first link should contain what you need to proceed with this tutorial).
Before loading the mesh layer in QGIS, we are going to add the world map as a background layer.
In QGIS, from the Browser panel, browse to the downloaded data > Working with mesh layer > vector_data.gpkg and add world_map layer.
You can change the project background layer to blue to have an image similar to the one below:
To add the mesh layer:
In QGIS, from the Browser panel, browse to the downloaded data > Working with mesh layer and add Hurricane Michael data from Copernicus ECMWF.nc as a mesh layer (not raster).
Depending on your QGIS settings, the CRS setting window might appear. Ensure you assign EPSG:4326 to the mesh layer.
To change the mesh layer style:
In QGIS, from the layers panel, select the mesh layer and press F7
The layer styling panel will appear on the right of your QGIS window
Within this panel, you can switch on/off quantities, vectors, style the layer and browse through time.
Below, we are going to switch on the wind data and style it:
On the Style panel, click on Symbology tab
wind to switch on the quantity**
Under color ramp section:
Set Min to 0
Set Max to 20
Interpolation to Linear
Color ramp to Blues (Inverted)
Mode to Equal Interval
Classes to 11
You can change the blending mode to Darken and you will see an image similar to the one below:
To style vector component of the wind data:
metre wind to switch on the vector**
Click on the vector settings section:
Enable the option for Display Vectors on User Grid
X Spacing: 10 px
**Y Spacing: 10 px **
For Arrow Length, select Scaled to Magnitude
If your mesh layer has time dimension, you should be able to browse through time using the slider provided under the settings tab:
Note that the time reference does not always parse correctly. To change the time (if you know the correct format and starting date/time):
Click on the setting in front of time
In the new window:
Use absolute time
Reference date/time: 29.09.2018 04:00:00
To plot time series, you will need to install Crayfish plugin from QGIS plugin repository. Once the plugin is installed:
In QGIS, from the main menu > Mesh > Crayfish > Plot
An empty plot appears at the bottom of your QGIS window. To generate time series for multiple points on the map:
Make sure you have the following settings
Layer: Hurricane Michale data from Copernicus ECMWF
Plot: Time series
And then click on From Map: Point
Hold Ctrl key on your keyboard and click on the locations you want to plot time series:
A series of graphs will be plotted for each point with matching colours.
You can also create long profile (including aggregated long plot) for a specific time step.
To export mesh to a raster or vector, you can use the processing toolbox:
In QGIS, from the main menu > Processing > Toolbox
Under Crayfish algorithm, double click on Rasterize
A new window will appear:
For Input mesh layer select Hurricane Michale data from Copernicus ECMWF
For Minimum extent click on … and select Use Layer Extent. In the new pop-up, select Hurricane Michale data from Copernicus ECMWF
For Map units per pixel, type: 0.500
For Dataset group, select 2 metre temperature
For Timestep, select 29 days, 6:00:00
Similarly, you can export your mesh to points or polygon for each time step.
To export to animation, you can set up a print layout template.
Ensure you have selected 10 m wind quantity from the mesh layer properties panel
Right-click on Hurricane Michael data from Copernicus ECMWF and select Export to animation
Set the correct parameters for start time/end time
Set the values for time, legend, title, etc
Set the filename for the animation file
Mesh calculator is similar to the Raster calculator with the following added functionalities:
Aggregate functions, e.g. calculate maximum values over time
Try to calculate the maximum precipitation values for Hurricane Michale data from Copernicus ECMWF dataset