QGIS Create a TIN

From Tuflow
Jump to navigation Jump to search

Introduction

TUFLOW offers powerful tools for modifying a model's geometry, including generating Triangulated Irregular Networks (TINs) from input data. Alternatively, users can create TINs in QGIS before importing them into TUFLOW. The advantage of this approach is that it allows the user to visualise and review the TINs before they are included in the model.

To demonstrate the workflow, the DEM and GIS files from Tutorial Module 2 (part 2) are used as examples. The instructions below refer to the GeoPackage format, but Shapefile format is also supported.

To create a TIN in QGIS, the following files are needed:

  • A DEM (raster) layer.
  • 2d_zsh (Z shape) layers that define topological modifications:
  • A polygon layer (e.g. 2d_zsh_M02_landscape_002_R)
  • At least one points layer containing elevation data (e.g. 2d_zsh_M02_landscape_002_P). These points should not be snapped to the polygon.
  • At least one breaklines layer (e.g. 2d_zsh_M02_landscape_002_L)
If multiple, repeat the Extract Elevation of Breakline Vertices process for each layer. Then, include all outputs in the Create TIN Mesh process.

Note: All features in the points and breaklines layers must be within the polygon extent.

Method

Densify Polygon Vertices

Densify the polygon vertices using the QGIS processing tool 'Densify by Interval'. For more information about this tool, please refer to the QGIS Documentation - Densify by Interval.

  1. In QGIS, open the polygon layer (e.g. TUFLOW\model\gis\2d_zsh_M02_landscape_002_R).
  2. Go to Processing > Toolbox from the top dropdown menu options to open the Processing Toolbox.

    Open processing toolbox.png

  3. Go to 'Vector geometry' in the processing tool list and select 'Densify by interval'. This opens the dialog shown below:
    • Input layer: Select the polygon (e.g. 2d_zsh_M02_landscape_002_R).
    • Interval between vertices to add: This value should be set to the smaller of the following two values - half the model cell size, or the finest Quadtree level.
    • Densified: Leave as default.
    • Tick on 'Open output file after running algorithm'.
  4. Click 'Run'. Once the tool is finished, click 'Close'.

    QGIS Create TIN Densify Polygon 01.png

  5. The resulting layer, called Densified will appear in the QGIS Layers panel. This is a copy of the polygon, now updated with additional vertices based on the specified interval.
  6. In the QGIS Layers panel, right click Densified and select 'Rename Layer'. Rename the layer to Densified_Polygon.
    Note: To see the vertices, toggle on editing for Densified_Polygon and select the 'Vertex Tool' Vertex tool icon.png from the Digitizing toolbar. Hover over the polygon to see the vertices.

    QGIS Create TIN Densify Polygon 02.png

Extract Elevation of Polygon Vertices from DEM

Extract elevation at polygon vertices from DEM using the QGIS processing tool 'Drape (set Z value from raster)'. For more information about this tool, please refer to QGIS Documentation - Drape.

  1. In QGIS, open the DEM file (e.g. TUFLOW\model\grid\DEM.tif).
  2. Go to 'Vector geometry' in the Processing Toolbox panel and select 'Drape (set Z value from raster)'. This opens the dialog shown below:
    • Input layer: Densified_Polygon
    • Raster layer: Select the DEM file.
  3. Leave all other options as default and ensure 'Open output file after running algorithm' is ticked on.
  4. Click 'Run'. Once the tool is finished, click 'Close'.

    QGIS Create TIN Drape Polygon 01.png

  5. The resulting layer, called Draped will appear in the QGIS Layers panel. Right click Draped and select 'Rename Layer'. Rename the layer to Draped_Polygon.

Generate IDW Interpolation

Generate a IDW (Inverse Distance Weighted) interpolation of the Z shape points layer (points layer containing elevation data), using the QGIS processing tool 'IDW Interpolation'. For more information about this tool, please refer to QGIS Documentation - IDW Interpolation.

  1. In QGIS, load all Z shape points layers within the polygon extent (e.g. TUFLOW\model\gis\2d_zsh_M02_landscape_002_P).
  2. Go to 'Interpolation' in the processing tool list and select 'IDW Interpolation'. This opens the dialog shown below:
    • Vector layer: Select the Z shape points layer (e.g. 2d_zsh_M02_landscape_002_P).
    • Interpolation attribute: Select Z. This is the attribute that contains elevation data.
    • Click QGIS 3D Animation add keyframe button 01.png to add the vector layer to the table.
    • If available, repeat the above three points for any other Z shape points layers within the polygon extent.
    • Distance coefficient P: Leave as default.
    • Extent: Click down arrow 40 and select 'Calculate from Layer' >> 'Draped_Polygon'.
    • Interpolated: Leave as default.
    • Tick on 'Open output file after running algorithm'.
  3. Click 'Run'. Once the tool is finished, click 'Close'.

    QGIS Create TIN IDW Interpolation 01.png

  4. The resulting file, called Interpolated will appear in the QGIS Layers panel.

    QGIS Create TIN IDW Interpolation 02.png

Extract Elevation of Breakline Vertices From IDW Interpolation

Extract elevation at breakline vertices from Interpolated using the QGIS processing tool 'Drape (set Z value from raster)'. For more information about this tool, please refer to QGIS Documentation - Drape.

  1. In QGIS, load the breaklines layer (e.g. TUFLOW\model\gis\2d_zsh_M02_landscape_002_L).
  2. Go to 'Vector geometry' in the Processing Toolbox panel and select 'Drape (set Z value from raster)'. This opens the dialog shown below:
    • Input layer: Select the breaklines layer (e.g. 2d_zsh_M02_landscape_002_L).
    • Raster layer: Interpolated
  3. Leave all other options as default and ensure 'Open output file after running algorithm' is ticked on.
  4. Click 'Run'. Once the tool is finished, click 'Close'.

    QGIS Create TIN Drape Lines 01.png

  5. The resulting layer, called Draped will appear in the QGIS Layers panel. Right click Draped and select 'Rename Layer'. Rename the layer to Draped_Lines.

Create TIN Mesh

Create a TIN Mesh using the QGIS processing tool 'TIN Mesh Creation'. This tool will generate a TIN mesh from the above outputs and any Z shape points layers (points layers containing elevation data). For more information about this tool, please refer to QGIS Documentation - TIN Mesh Creation.

  1. Go to 'Mesh' in the Processing Toolbox panel and select 'TIN Mesh Creation'. This opens the dialog shown below:
    • Vector Layer: Draped_Lines
    • Value on Vertex: Leave as default and tick on 'Use Z-coordinate for Value on Vertex'.
    • Click QGIS 3D Animation add keyframe button 01.png to add the vector layer to the table.
    • Repeat the above three points for Draped_Polygon.
    • If there are any Z shape points layers within the polygon extent, add these as well. For 'Value on Vertex', select the field that contains the elevation data (e.g. Z).
    • Output format: 2DM
    • Output coordinate system: Use the project CRS.
    • Output file: Save to the model's grid folder (TUFLOW\model\grid). Ensure the file extension is .2dm (e.g. TIN_Mesh.2dm).
  2. Click 'Run'. Once the tool is finished, click 'Close'.

    QGIS Create TIN Create Mesh 01a.png

  3. The resulting layer will appear in the QGIS Layers panel.
  4. To view the triangular mesh, right click the TIN Mesh and select 'Properties'.
  5. In the 'Symbology' tab, select 'Rendering' from the top options and tick on 'Triangular Mesh Rendering'. Click 'OK'.

    QGIS Create TIN Create Mesh 02.png

Update TUFLOW Geometry Control File (TGC)

The TUFLOW Geometry Control File (.tgc) must be updated to reference the TIN Mesh, which will replace any topography-modifying GIS layers (Z shapes) within the mesh extent.

Remove all references to Z shapes (Read GIS Z Shape == ) in the TGC file and replace them with: Read TIN Zpts == grid\<TIN_Mesh_filename>.2dm | <polygon_filename>

Note: The polygon is included in the command to ensure that the TIN is only applied within the extent of the polygon.

For example:
Set Zpts == 100  ! Sets every 2D elevation zpt to 100 metres
Read GRID Zpts == grid\DEM.tif  ! Assigns the elevation of zpts from the grid
! Read GIS Z Shape == 2d_zsh_M02_landscape_002_R | 2d_zsh_M02_landscape_002_L | 2d_zsh_M02_landscape_002_P ! Defines areas of complex landscaping
Read TIN Zpts == grid\TIN_Mesh.2dm | 2d_zsh_M02_landscape_002_R  ! Defines areas of complex landscaping

Additional Resources

For more information on TUFLOW's triangulation methods, please refer to the TUFLOW Manual.


Up
Go-up.png Back to QGIS Tips And Tricks