SWAN GIS Model Builder
This page guides you through the SWAN GIS Model Builder Panel of the TUFLOW Viewer Plugin and is the third step the step by step guide. We will use the Model Builder Panel to:
Building Model in QGIS
- Start QGIS (version 3.16.3 or later). Under the plugins menu, navigate to the plugins/TUFLOW/SWAN GIS Tools (beta)/Model Builder. If you don't have this option please ensure that you've installed the TUFLOW Viewer Plugin for QGIS.
- It's important that we set the working coordinate reference system. This will be used as the default coordinate reference system for our SWAN grid files and will ensure that our model grids, bathymetries, wind and wave inputs are correctly aligned. Not completing this step is a common source of error when running the SWANGIS tools. For this tutorial set the coordinate reference system to WGS84 longitude/latitude or EPSG:4326. Please note that the SWANGIS tools assume all input datasets are in the same coordinate reference system.
Filter by typing in 4326 to select the EPSG for WG84 Long/Lat. Then click ok.
- Set the default coordinate reference system options for all QGIS projects via the Settings >> Options menu.
Go to the CRS tab. We want to change the default CRS for layers with no coordinate system assigned to be the same as the project coordinate reference system.
- Set the SWAN folder path at the top of the model builder window, this is the location where all SWAN model files will be saved (see model folder setup). If following the tutorial we will set the path to C:\Tutorial_Module_SWAN_GIS_Tools\Moreton_Bay_Waves\SWAN.
Setup Configuration File
- Create a new parameter configuration file by following these steps:
- Press the spanner icon in the 'Configuration File Input' row
- Set the parameter inputs to desired values. In this instance we will stick with the default values.
- Press the 'Save As' button
- Save file to C:\Tutorial_Module_SWAN_GIS_Tools\Moreton_Bay_Waves\SWAN\CONFIG.ini
Open the saved configuration file in a text editor. The configuration file contains text that describes the assignment of model parameters. The model builder will use the model parameters as set in the configuration file.
- Set the file path of the newly created configuration file in the model builder:
Define Model Domains
- Create a new grid layer by pressing the 'New Grid Layer' button. Save the new grid layer to C:\Tutorial_Module_SWAN_GIS_Tools\Moreton_Bay_Waves\QGIS\SWAN_GRIDS_000.shp
When saved, the new layer will automatically be loaded and styled in the QGIS project.
- Create a new polygon for the first model grid in the newly created layer by following these steps:
- Select the newly created grid layer in the 'Grid Layer Input'
- Select the grid layer in the QGIS layers tree
- Unlock the grid layer for editing
- Digitise a polygon that covers the desired model extent, approximately [-29.5 -25] latitude and [152.5 156] longitude (it is recommended you use 'add rectangle from extent')
Note: You don't need to exactly follow the polygons we have created, but please use them as a guide.
For our model domain we will start with a relatively coarse mesh of Moreton Bay and the continental shelf and then add higher resolution through two levels of nesting.
When the feature is added to the layer, a new grid parameter input row will be created in the model builder, it will be blank as no parameters are set.
It is important once a grid layer has been selected that it, or any generated mesh layers, are not removed from the QGIS project as the SWAN GIS tools need to maintain a reference to the selected layer at all times. To prevent users accidentally removing the grid layer, it becomes 'locked' when selected such that users cannot remove it from the project until it is deselected.
- Apply the following values to populate the row:
Name Rotation X Length Y Length REGIONAL 0 0.05 0.05
On setting the values, a mesh of the computational grid will be automatically generated and displayed.
- Repeat the above steps and add three more polygons, nesting them inside each other in similar locations as below and with the following names and parameters:
Name Rotation X Length Y Length REGIONAL 0 0.050 0.050 TRANSITION 0 0.025 0.025 NORTH_MORETON 0 0.005 0.005 POINT_LOOKOUT 0 0.005 0.005
Approximate bounding box coordinates for each grid are provided as follows:
Name X Min X Max Y Min Y Max REGIONAL 152.5 156.0 -29.5 -25.0 TRANSITION 153.0 154.5 -28.3 -26.2 NORTH_MORETON 153.1 153.5 -27.1 -26.7 POINT_LOOKOUT 153.5 153.8 -27.7 -27.3
Once you are happy with your model boundaries save your edits and toggle editing off.
Save Model Builder State
- We will now save the state of the model builder for demonstrative purposes. Press the 'save as button' and save your ini file to: C:\Tutorial_Module_SWAN_GIS_Tools\Moreton_Bay_Waves\SWAN\BUILD.ini. Note this does not save the 'grid input layer'. This layer is edited and saved as per normal QGIS layer editing interface.
- Open the newly created BUILD.ini file in a text editor. As shown, the BUILD.ini file is a simple text file which stores the input\output of the model builder for loading at a later time.
Load Bathymetry, Wind and Wave Datasets
- Load the bathymetry datasets described in the Getting Data section into QGIS. If following along with the tutorial these datasets should be within: C:\Tutorial_Module_SWAN_GIS_Tools\Moreton_Bay_Waves\DATA\BATHY
- Use the bathymetry layer selector to add the Digital Terrain Models (DTM) one by one in decreasing order of priority (layer on bottom of list will be overwritten by layers above).
The layers stored in this list are used to generate the bottom input files by interpolating values to the computational grid.
- Set the wind source and wave source file inputs. These are references to the data files discussed in the Getting Data section. If following along with the tutorial these dataset should be within: C:\Tutorial_Module_SWAN_GIS_Tools\Moreton_Bay_Waves\DATA\WIND and C:\Tutorial_Module_SWAN_GIS_Tools\Moreton_Bay_Waves\DATA\WAVE
Set the Time Period and Build Run
- Set the start and end dates to a period which is covered by the wind and wave data sources then press the 'Build Run' button. This will generate and save the SWAN model input and control files into our SWAN folder.
Please note that the creation of the SWAN model files and geometry may take up to minute to complete.
ConclusionYou have now successfully populated and run the SWAN GIS Model Builder panel. Next, we will review the various check files, boundary files and control files generated by the model build in the fourth step of our SWAN GIS tutorial.