View Results in QGIS
In this section we will look at post-processing the TUFLOW results so they can be imported and viewed in QGIS. We will bring 3D surfaces (as gridded datasets) as well as point and vector data (as region objects).
TUFLOW to GIS
In order to bring the 2D results written by TUFLOW (for example a water level surface) into QGIS it is necessary to utilise a TUFLOW utility called TUFLOW_to_GIS.exe this utility can be downloaded from the TUFLOW website (TUFLOW Downloads).
There is separate wiki page on how to use the TUFLOW_to_GIS utility. This page can be found here TUFLOW to GIS.
- Download the TUFLOW_to_GIS utility and unzip. Take note of where this utility is located.
- Create an empty text file in the TUFLOW\results\M01\2d\ directory and name the file Process_Results.bat
- Open the text file in a text editor
- Add the following lines to the Process_Results.bat (these can be copied and pasted from below) and then save the batch file:
REM Any text following "REM" is treated as a remark or comment.
REM Process the maximums for water level, depth and velocity.
C:\TUFLOW\Utilities\TUFLOW_to_GIS.exe -b -asc -max M01_5m_002_h.dat
C:\TUFLOW\Utilities\TUFLOW_to_GIS.exe -b -asc -max M01_5m_002_V.dat
C:\TUFLOW\Utilities\TUFLOW_to_GIS.exe -b -asc -max M01_5m_002_d.dat
REM Process the depths at times 1, 2 and 3 hours.
C:\TUFLOW\Utilities\TUFLOW_to_GIS.exe -b -asc -t1 M01_5m_002_d.dat
C:\TUFLOW\Utilities\TUFLOW_to_GIS.exe -b -asc -t2 M01_5m_002_d.dat
C:\TUFLOW\Utilities\TUFLOW_to_GIS.exe -b -asc -t3 M01_5m_002_d.dat
REM Process the velocity vectors at times 1, 2 and 3 hours.
C:\TUFLOW\Utilities\TUFLOW_to_GIS.exe -b -shp -vector -t1 M01_5m_002_V.dat
C:\TUFLOW\Utilities\TUFLOW_to_GIS.exe -b -shp -vector -t2 M01_5m_002_V.dat
C:\TUFLOW\Utilities\TUFLOW_to_GIS.exe -b -shp -vector -t3 M01_5m_002_V.dat
Pause REM this keeps the Command Window open after processing
- In Windows Explorer navigate to the TUFLOW\results\M01\2d\ directory and double click on the newly created batch file Process_Results.bat.
Update the path to TUFLOW_to_GIS.exe if necessary.
A console window should appear and the batch file may process for a minute or so. When finished the output screen should look like screen image below:
In windows explorer there should be 18 new files created, 6 .asc files and 12 files (3 conversions with 4 file created) for each of the vector sets.
TIP: If there are not 18 files created remove the -b switches from the batch file and re-run the batch file. The TUFLOW_to_GIS utility will prompt for an input after each command line. This can be useful in determining why the process has stopped.
Viewing in QGIS
- If it is not already open, start QGIS and load the aerial photo (Module_Data\Aerials\QGIS\).
- Firstly we will open the gridded (raster) datasets, to do this select Layers >>> Add Raster Layer. Navigate to the TUFLOW\Results\M01\2d\ folder and select all of the .asc files.
- As can be seen the results are showing up as grey. We will give these a colour shading to make the results more meaningful. We will use the M01_5m_002_d_g002.50_Max to demonstrate how this is done. Turn of the other results layer so that only the M01_5m_002_d_g002.50_Max and Aerial_Photo_M01 are visible.
- Right click on the M01_5m_002_d_g002.50_Max layer and select properties.
- In the style tab, change the Colour Map' to from Greyscale to Colour
- Navigate to the Colourmap tab. Set the Colour Interpolation to Linear. A colour ramp can be created by adding values with the Add Entry button. In the example below, three entries have been added, with a value (depth) of 0 showing as white, 2 as blue and 6 as black.
- Alternatively this colour scheme can be loaded from the Module_Data\Module_01\QGIS\colourmap_depth.txt
- Select OK and Apply. The map window should now show a shaded depth grid, as per the image below.
- We will now look at the water level results. Turn off the M01_5m_002_d_g002.50_Max and turn on the M01_5m_002_h_g002.50_Max. Following a similar process as above, enter the properties, set the style to colourmap and navigate to the colourmap tab. Set the Colour interpolation to Linear. Instead of adding the entries as we did previously in the generate colourmap section enter 10 into the Number of Entries section and click on Classify button. A colour ramp will be automatically generated. Select Apply and then OK. The results should appear as per the 2nd image below.
Tip: An easy way to do this is to type *.asc into the filename dialogue.
The map window should now show the grids over the aerial photo, as per the image below.
- To contour the results to discrete values, for example to contour the water level at 1m increments. Select Raster >>> Contour'.
- In the Contour dialogue, set the following:
- Input file (raster) to the water level results - M01_5m_002_h_g002.50_Max;
- Set an appropriate output file name (in the example this is Cont_M01_5m_002_h_Max);
- Interval between contour lines to 1.0 (metres);
- Tick the Attribute name (this includes the elevation on each contour); and
- Tick the load into canvas when finished.
- The contour lines should now be displayed on the map as per the image below.
- The vector outputs from the TUFLOW_to_GIS conversion can be directly loaded into QGIS. Select Layer >>> Add Vector Layer.
- Select the three velocity vector results, from the TUFLOW\results\M01\2d\ directory.
- Turn all layers except the aerial photo, M01_5m_002_d_g002.50____1.00 (the depth at time 1 hour) and the M01_5m_002_V____1.00(v)_R (velocity vector at time 1 hour).
- Colour the depth grid, using the method above.
Tip: Use the colourmap provided in the module data directory, or save the colour profile created earlier. The depth and velocity results at time 1 hour should now be visible.
- Repeat the process above to view the results at 2 and 3 hours into the simulation.
We have covered the basics of viewing 2D TUFLOW results in QGIS. Please return to the tutorial model, module 1. In the next step we review the performance of the TUFLOW model (warnings, checks and mass balance), to return please click here