16. Working with Mesh Data

16.1. What’s a mesh?

A mesh is an unstructured grid usually with temporal and other components. The spatial component contains a collection of vertices, edges and faces in 2D or 3D space:

  • vertices - XY(Z) points (in the layer’s coordinate reference system)

  • edges - connect pairs of vertices

  • faces - a face is a set of edges forming a closed shape - typically a triangle or a quadrilateral (quad), rarely polygons with more vertices

../../../_images/mesh_grid_types.png

Fig. 16.1 Different mesh types

QGIS can currently render mesh data using triangles or regular quads.

Mesh provides information about the spatial structure. In addition, the mesh can have datasets (groups) that assign a value to every vertex. For example, having a triangular mesh with numbered vertices as shown in the image below:

../../../_images/triangual_grid_with_numered_vertices.png

Fig. 16.2 Triangular grid with numbered vertices

Each vertex can store different datasets (typically multiple quantities), and those datasets can also have a temporal dimension. Thus, a single file may contain multiple datasets.

The following table gives an idea about the information that can be stored in mesh datasets. Table columns represent indices of mesh vertices, each row represents one dataset. Datasets can have different datatypes. In this case, it stores wind velocity at 10m at a particular moments in time (t1, t2, t3).

In a similar way, the mesh dataset can also store vector values for each vertex. For example, wind direction vector at the given time stamps:

10 metre wind

1

2

3

10 metre speed at time=t1

17251

24918

32858

10 metre speed at time=t2

19168

23001

36418

10 metre speed at time=t3

21085

30668

17251

10m wind direction time=t1

[20,2]

[20,3]

[20,4.5]

10m wind direction time=t2

[21,3]

[21,4]

[21,5.5]

10m wind direction time=t3

[22,4]

[22,5]

[22,6.5]

We can visualize the data by assigning colors to values (similarly to how it is done with Singleband pseudocolor raster rendering) and interpolating data between vertices according to the mesh topology. It is common that some quantities are 2D vectors rather than being simple scalar values (e.g. wind direction). For such quantities it is desirable to display arrows indicating the directions.

../../../_images/mesh_visualisation.png

Fig. 16.3 Possible visualisation of mesh data

16.2. Supported formats

QGIS accesses mesh data using the MDAL drivers. Hence, the natively supported formats are:

  • NetCDF: Generic format for scientific data

  • GRIB: Format commonly used in meteorology

  • XMDF: As an example, hydraulic outputs from TUFLOW modelling package

  • DAT: Outputs of various hydrodynamic modelling packages (e.g. BASEMENT, HYDRO_AS-2D, TUFLOW)

  • 3Di: 3Di modelling package format based on Climate and Forecast Conventions (http://cfconventions.org/)

  • Some examples of mesh datasets can be found at https://apps.ecmwf.int/datasets/data/interim-full-daily/levtype=sfc/

To load a mesh dataset into QGIS, use the addMeshLayer Mesh tab in the Data Source Manager dialog. Read Loading a mesh layer for more details.

16.3. Mesh Dataset Properties

16.3.1. Information Properties

../../../_images/mesh_info_properties.png

Fig. 16.4 Mesh Layer Properties

The Information tab is read-only and represents an interesting place to quickly grab summarized information and metadata on the current layer. Provided information are:

  • based on the provider of the layer: name, path, extent, vertex, face, edges and/or dataset groups count

  • the Coordinate Reference System: name, units, method, accuracy, reference (i.e. whether it’s static or dynamic)

  • extracted from filled metadata: access, extents, links, contacts, history…

16.3.2. Source Properties

The Source tab displays basic information about the selected mesh, including:

  • the Layer name to display in the Layers panel

  • setting the Coordinate Reference System: Displays the layer’s Coordinate Reference System (CRS). You can change the layer’s CRS by selecting a recently used one in the drop-down list or clicking on setProjection Select CRS button (see Coordinate Reference System Selector). Use this process only if the CRS applied to the layer is wrong or if none was applied.

Use the Assign Extra Dataset to Mesh button to add more groups to the current mesh layer.

16.3.3. Symbology Properties

Click the symbology Symbology button to activate the dialog. Symbology properties are divided into several tabs:

16.3.3.1. Datasets

The tab general Datasets is the main place to control and set which datasets will be used for the layer. It presents the following items:

  • Groups available in the mesh dataset, with whether they provide:

    • meshcontoursoff scalar dataset

    • or meshvectorsoff vector dataset: by default, each vector dataset has a scalar dataset representing its magnitude automatically generated.

    Click on the icon next to the dataset name to select the group and type of data to represent.

  • Selected dataset group(s) metadata, with details on:

    • the mesh type: edges or faces

    • the data type: vertices, edges, faces or volume

    • whether it’s of vector type or not

    • the original name in the mesh layer

    • the unit, if applicable

  • blending mode available for the selected datasets.

../../../_images/mesh_symbology_datasets.png

Fig. 16.5 Mesh Layer Datasets

You can apply symbology to the selected vector and/or scalar group using the next tabs.

16.3.3.2. Contours Symbology

Note

The meshcontours Contours tab can be activated only if a scalar dataset has been selected in the general Datasets tab.

In the meshcontours Contours tab you can see and change the current visualization options of contours for the selected group, as shown in Fig. 16.6 below:

../../../_images/mesh_symbology_contours.png

Fig. 16.6 Styling Contours in a Mesh Layer

  • Use the slider or the spinbox to set the Opacity of the current group.

  • Use refresh Load to adjust the min and max values of the current group or enter custom values if you want to exclude some.

  • Select the Resampling method

  • Classify the dataset using the color ramp shader classification.

16.3.3.3. Vectors Symbology

Note

The meshvectors Vectors tab can be activated only if a vector dataset has been selected in the general Datasets tab.

In the meshcontours Vectors tab you can see and change the current visualization options of vectors for the selected group, as shown in Fig. 16.7:

../../../_images/mesh_symbology_vectors.png

Fig. 16.7 Styling Vectors in a Mesh Layer with arrows

Mesh vector dataset can be styled using various types of Symbology:

  • Arrows: vectors are represented with arrows at the same place as they are defined in the raw dataset (i.e. on the nodes or centre of elements) or on a user-defined grid (hence, they are evenly distributed). The arrow length is proportional to the magnitude of the arrow as defined in the raw data but can be scaled by various methods.

  • Streamlines: vectors are represented with streamlines seeded from start points. The seeding points can start from the vertices of the mesh, from a user grid or randomly.

  • Traces: a nicer animation of the streamlines, the kind of effect you get when you randomly throws sand in the water and see where the sand items flows.

Available properties depend on the selected symbology as shown in the following table.

Label

Description and Properties

Arrow

Streamlines

Traces

Line width

Width of the vector representation

checkbox

checkbox

checkbox

Coloring method

  • a Single color assigned to all vectors

  • or a variable color based on vectors magnitude, using a Color ramp shader

checkbox

checkbox

checkbox

Filter by magnitude

Only vectors whose length for the selected dataset falls between a Min and Max range are displayed

checkbox

checkbox

Display on user grid

Places the vector on a grid with custom X spacing and Y spacing and interpolates their length based on neighbours

checkbox

checkbox

Head options

Length and Width of the arrow head, as a percentage of its shaft length

checkbox

Arrow length

  • Defined by Min and Max: You specify the minimum and maximum length for the arrows, QGIS will interpolate their size based on the underlying vector’s magnitude

  • Scale to magnitude: arrow length is proportional to their vector’s magnitude

  • Fixed: all the vectors are shown with the same length

checkbox

Streamlines seeding method

  • On mesh/grid: relies on the user grid to display the vectors

  • Randomly: vector placement is randomly done with respect to a certain density

checkbox

Particles count

The amount of “sand” you want to throw into visualisation

checkbox

Max tail length

The time until the particle fades out

checkbox

16.3.3.4. Rendering

In the tab meshframe, QGIS offers two possibilities to display the grid, as shown in Fig. 16.8:

  • Native Mesh Rendering that shows quadrants

  • Triangular Mesh Rendering that display triangles

../../../_images/mesh_symbology_grid.png

Fig. 16.8 Mesh Rendering

The line width and color can be changed in this dialog, and both the grid renderings can be turned off.

16.3.3.5. Stacked mesh averaging method

3D layered meshes consist of multiple stacked 2D unstructured meshes each extruded in the vertical direction (levels) by means of a vertical coordinate. The vertices and faces have the same topology in each vertical level. Values are usually stored on the volumes that are regularly stacked over base 2d mesh. In order to visualise them on 2D canvas, you need to convert values on volumes (3d) to values on faces (2d) that can be shown in mesh layer. The meshaveraging Stacked mesh averaging method provides different averaging/interpolation methods to handle this.

You can select the method to derive the 2D datasets and corresponding parameters (level index, depth or height values). For each method, an example of application is shown in the dialog but you can read more on the methods at https://fvwiki.tuflow.com/index.php?title=Depth_Averaging_Results.

16.3.4. Metadata Properties

The editMetadata Metadata tab provides you with options to create and edit a metadata report on your layer. See Metadata for more information.