Skip to article frontmatterSkip to article content
Site not loading correctly?

This may be due to an incorrect BASE_URL configuration. See the MyST Documentation for reference.

Pre-processing with QGIS

The first steps in numerical modeling of a river with BASEMENT consist in the conversion of a Digital Elevation Model (DEM) into a computational mesh. This tutorial guides through the creation of a QGIS project for converting a DEM (GeoTIFF) into a computational mesh that can be used with various numerical modeling software featured in this eBook. At the end of this tutorial, BASEMENT users will have generated a computational grid in the SMS 2dm format.

QGIS Setup

Coordinate Reference System (CRS)

Launch QGIS and create a new QGIS project to get started with this tutorial. As featured in the QGIS Tutorial, set up a coordinate reference system (CRS) for the project. This example uses data of a river in Bavaria (Germany zone 4), which requires the following CRS:

qgis set coordinate reference system crs germany zone_4 Inn river

Figure 1:Define Germany_Zone_4 as project CRS.

Get the BASEmesh Plugin

Install BASEMENT’s BASEmesh Plugin (instructions from the BASEMENT System Manual):

qgis basement plugins

Figure 2:Add the BASEMENT repository to QGIS’ Plugins Manager.

qgis basement plugins

Figure 3:The BASEmesh 2 plugin is available in QGIS’ Plugins menu after the successful installation.

Load DEM

This tutorial uses an application-ready DEM in GeoTIFF Gridded Cell (Raster) Data format that stems from a Lidar point cloud. The DEM raster provides height (Z) information from a section of a gravel-cobble bed river in South-East Germany, which constitutes the baseline for the computational grids featured in the next sections. To get the provided DEM in the QGIS project:

The DEM should now be displayed on the map (if not: right-click on the DEM layer and click on Zoom to Layer(s) in the context menu) as shown in Fig. 4.

qgis import raster DEM basemap

Figure 4:The imported DEM on a Google Satellite imagery basemap (source: Google / GeoBasis-DEBKG 2019). The flow direction is from left to right following the Q arrow.

Create 2dm Mesh

The generation of a SMS 2dm uses the QGIS BASEmesh plugin and requires drawing a

These shapefiles enable to generate a Quality Mesh. Ultimately, height information is interpolated to the quality mesh and the resulting mesh is saved as SMS 2dm file. The next sections walk through the procedure step by step with detailed explanations. Additional materials and intermediate data products are provided in the supplemental data repository (materials-bm) for this tutorial.

Model Boundary and Breaklines

The model boundary defines the model extent and can be divided into regions with different characteristics (e.g., roughness values) through breaklines. Breaklines indicate, for instance, channel banks and the riverbed (main channel), and need to be inside the DEM extents. Boundary lines and breaklines are stored in a Line Shapefile that BASEmesh uses to find both model boundaries and internal breaklines between model regions. For this purpose, Create a Line Shapefile with one Text Field called LineType and call it breaklines.shp (Layer > Create Layer > New Shapefile Layer). Click on QGIS’ Layers menu > Create Layer > New Shapefile Layer... (see Fig. 5). Make sure to select ESRI: 31494 - Germany_Zone_4 as CRS .

qgis new layer basemesh

Figure 5:Create a new shapefile from QGIS’ Layers menu.

It is important that the lines do not overlap to avoid ambiguous or missing definitions of regions and to ensure that all boundary lines form closed regions (areas). Therefore, activate snapping:

Next, start to edit breaklines.shp by clicking on the yellow pen and draw the lines indicated in Fig. 6 by activating Add Line Feature .

To correct drawing errors use the Vertex Tool . Finally, save the new lines (edits of breaklines.shp) by clicking on the Save Layer Edits symbol. Stop (Toggle) Editing by clicking again on the yellow pen symbol.

qgis basement basemesh draw breaklines boundaries

Figure 6:Boundary and breaklines to draw in breaklines.shp. Left and right banks and floodplains are orientated in the flow direction (Q arrow).

The default layer style is Single Symbol. For better representation, double-click on the breaklines layer, go to the Symbology tab and select Categorized (or Graduated) instead of Single Symbol (at the very top of the Layer Properties window). In the Value field, select LineType, then click the classify button on the bottom of the Layer Properties window. The listbox will now show the LineType values.

Liquid (Hydraulic) Boundaries

The liquid boundaries define where hydraulic conditions, such as a given discharge or stage-discharge relationship, apply at the model inflow (upstream) and outflow (downstream) limits. Thus, a functional river model requires at least one inflow boundary (line) where mass flow into the model and one outflow boundary (line) where mass fluxes leave the model. For this purpose, Create a Line Shapefile called liquid-boundaries.shp and define two text data fields named type and stringdef. Make sure that snapping is still enabled (as above explained in the Model Boundary and Breaklines section) and Toggle (Start) Editing the new liquid-boundaries.shp. Then draw two lines:

qgis basemesh draw inflow boundary line

Figure 7:The inflow boundary line is drawn from the left to the right (i.e., the upstream flow is coming from the right-hand side of the inflow boundary line). The sequence of buttons to use is highlighted by the red boxes.

qgis basemesh draw outflow boundary line

Figure 8:The outflow boundary line is drawn from the top to the bottom (i.e., the upstream flow is coming from the right hand-side of the outflow boundary line).

Finally, save the liquid boundary lines (edits of liquid-boundaries.shp) by clicking on the Save Layer Edits symbol. Stop (Toggle) Editing by clicking again on the yellow pen symbol.

Region Markers

Region markers are placed inside regions defined by boundary lines and breaklines. Every region marker (i.e., a point somewhere in the region area) assigns, for instance, a material identifier (MATIDs) and a maximum mesh cell area. The latter option enables to define small mesh cells (mesh areas) in the active channel bed and can larger cell areas in the floodplain regions. Create a Point Shapefile named raster-points.shp with the following definitions (see also Fig. 9):

basement mesh qgis region layer points

Figure 9:Definitions and fields to be added to the region-points shapefile.

Consider to deactivate snapping for drawing the region markers to avoid that region markers coincide with any line. Then, Toggle (Start) Editing the new region-points.shp file and activate Add Point Feature . Draw one point in every area section that is enclosed by breaklines and (liquid) boundary lines. Depending on the apparent area type from the satellite imagery basemap, assign one of the five regions listed in Tab. 1 to every point.

Table 1:Region names and their max_area, MATID, and type field values.

Region

Riverbed

Block ramps

Gravel banks

Floodplains

Sand

max_area

25.0

20.0

25.0

80.0

20.0

MATID

1

2

3

4

5

type

riverbed

block_ramp

gravel_bank

floodplain

sand_deposit

After drawing a point in every closed area, save the region point markers (edits of region-points.shp) by clicking on the Save Layer Edits symbol. Stop (Toggle) Editing by clicking again on the yellow pen symbol. Figure 10 shows an example for region marker points within the areas delineated by the breaklines.

basemesh region points

Figure 10:Example for region point markers in the project boundaries.

Create a Quality Mesh

BASEmesh’s quality mesh tool creates a computationally efficient triangular mesh based on Shewchuk (1996) and within the above-defined model boundaries. The tool associates mesh properties with the regions shapefile ([see above section on Region Markers), but it does not include elevation data. Thus, after generating a quality mesh, elevation information needs to be added. This section explains the quality mesh generation and the next section features the interpolation of bottom elevations.

In QGIS’ Plugins menu, click on BASEmesh 2 > QUALITY MESHING to open the quality mesh tool. Make the following settings in the popup window (see also Fig. 11):

basement qgis quality mesh tin

Figure 11:Definitions to be made in BASEmesh’s Quality meshing tool.

Quality meshing may take time. After a successful mesh generation the file prepro-tutorial_quality-mesh-interp.2dm will have been generated.

Interpolate Bottom Elevation to Quality Mesh

The BASEmesh plugin’s Interpolation tool projects bottom elevation data onto the quality mesh by interpolation from another mesh or a DEM Gridded Cell (Raster) Data. Here, we use the above-introduced DEM GeoTIFF. To run the interpolation, open BASEmesh’s Interpolation tool (QGIS Plugins menu > BASEmesh 2 > Interpolation) and make the following settings (see also Fig. 12):

qgis quality mesh interpolation basement

Figure 12:BASEmesh’s Z-value (height) interpolation tool and setup to assign bottom elevation values to the quality mesh.

After the elevation interpolation, verify that the elevations are correctly assigned (i.e., the Bed Elevation should have taken values between 367 and 387 m a.s.l.). To modify the layer visualization (symbology) double-click on the new prepro-tutorial_quality-mesh-interp and go to the Symbology ribbon. Select Graduated at the very top of the window, set the Value to Z, Method to COLOR, choose a color ramp, and click on the classify bottom (lower part of the window). Click on Apply and OK to close the symbology settings. Figure 13 shows an example visualization of the height-interpolated mesh.

basemesh verify interpolated quality mesh

Figure 13:Verify elevation interpolation using graduated color ramps.

Usage with BASEMENT

The 2dm mesh file produced in this tutorial can be directly used with BASEMENT, where only the definition of properties of the geometric (e.g., roughness coefficients) and liquid (e.g., discharges) are required as explained later.

References
  1. Shewchuk, J. R. (1996). Triangle: Engineering a 2D quality mesh generator and Delaunay triangulator. In M. C. Lin & D. Manocha (Eds.), Applied Computational Geometry Towards Geometric Engineering (pp. 203–222). Springer. 10.1007/BFb0014497