Advanced GIS Updates

From TUFLOW FV Wiki
Jump to navigation Jump to search
USEFUL LINKS
Wiki Links Help Downloads
TUFLOW FV Wiki Main Page Products Support/Contact TUFLOW FV Downloads
TUFLOW FV Tutorials Requesting a Licence Tutorial Module Data
TUFLOW Classic/HPC Wiki TUFLOW FV Glossary Manuals

Pre-requisites

The GIS component of this tutorial assumes you have completed the GIS introduction provided in GIS Integration Part 1.

Set GIS Projection and Create Empty Files

Firstly, we need to configure the TUFLOW Viewer Plugin. You may recall this was completed during the GIS component of Tutorial Model 01. For a full overview of how to configure the TUFLOW Viewer Plugin and what it is completing please refer to Configure model using QGIS.

As completed in Tutorial Model 01, set the working folder to the location of your TUFLOWFV folder. Additionally set the Projection to WGS 84 / UTM Zone 60S and specify the path to your TUFLOWFV executable.

Tute 3 advanced GIS 001.png

Geometry Update using GIS File

The original Tutorial Model 03 updates cell elevations by reading CSV files. However, in this section of the tutorial this has been updated with efficient direct reading of GIS inputs. In this tutorial we will introduce advanced topography updates using GIS functions, including:

  • Interpolating ZB elevations from an input DEM,
  • Using a combination of lines and points to specify varied bed elevations along polylines,
  • Setting a uniform bed elevation inside a polygon.

Copy model input files:

1. Copy and save the Create_Empties.fvc file (refer TUFLOW FV Empty GIS Files) in the TUFLOWFV\runs folder as FMA2_Hydro_002_GIS.fvc and open this file in Notepad++. At this point, this file only contains the command to define the GIS format and model projection. We will edit this file to create a new run file. For a full overview on creating TUFLOW FV empty GIS files please refer to TUFLOW FV Empty GIS Files.

2. Comment out the last command since we don’t need to generate empty files again.

GIS FORMAT == SHP
SHP Projection == ..\model\gis\projection.prj
Tutorial Model == ON
!Write Empty GIS Files == ..\model\gis\empty

3. Go to the folder Complete_Model\TUFLOWFV\runs and copy the original tutorial FVC file FMA2_Hydro_002.fvc across to our working folder the TUFLOWFV\runs folder.

4. Copy across ALL commands from FMA2_Hydro_002.fvc to the newly created FMA2_Hydro_002_GIS.fvc file, below the existing lines of code.

Note: If you have already succesfully created and run FMA2_Hydro_002.fvc from the TUFLOWFV\runs folder during the non GIS part of the tutorial please skip steps 5-8.

5. Copy across the following files from the Module_Data directory to the corresponding folders:

  • inflows.csv and Tide.csv from the Module_Data\Boundary_Conditions directory to the .\TUFLOWFV\bc_dbase\ folder,
  • FMA2_FV01_Zb0m.2dm from the Module_Data\Geometry directory to our .\TUFLOWFV\model\geo\ folder. All the vertex elevations are set as 0m in this 2dm file,
  • All the files that start with 2d*, from the Module_Data\Geometry\GIS to the .\TUFLOWFV\model\gis\ directory.

6. Create a .\TUFLOWFV\model\struct folder and copy across the files from the Module_Data\Geometry\STRUCT directory,

7. Create a .\TUFLOWFV\model\grid folder in your working directory and copy the DEM_5m.asc file from the Module_Data\Geometry\GRID directory into it. The bed elevations stored in this file will be read by a GIS command,

8. Create a .\TUFLOWFV\model\csv folder and copy across the files from the Module_Data\Geometry\CSV directory.

Update GIS inputs and FVC commands

1. Update the 2dm file read by the model:

Geometry 2D  == ..\model\geo\FMA2_FV01_Zb0m.2dm

2. On the next line down add a default value for the bed elevation above any expected modelled water level by adding the following command:

Set Zpts  == 99

Review GIS files in QGIS

1. Open the orthophoto.jpg from .\Module_Data\Geometry\APH file and the DEM_5m.asc file from the .\TUFLOWFV\model\grid\ folder in QGIS.

2. For improved viewing of the DEM, double click on the DEM_5m layer and change the render type to singleband pseudocolor:

Tute 3 advanced GIS 002.png

Additionally, change the min and max values to -5 and 25m respectively.

3. Review the bed elevations stored in the DEM. This can be done by using the identify features button as shown below:

Tute 3 advanced GIS 003.png

Tute 3 advanced GIS 004.png

4. To read the DEM as the source of ZB data add the following command to FMA2_Hydro_002_GIS.fvc within the geometry commands:

Read Grid Zpts  == ..\model\grid\DEM_5m.asc

5. In QGIS, open the 2d_zln_Road_Breakline_001_P.shp and 2d_zln_Gully_Breakline_001_P.shp layers from the .\TUFLOWFV\model\gis\ folder (as copied previously). Additionally, open the Land_Fill.shp file from the Module_Data\Geometry\GIS folder to check the GIS objects and attributes. The layers include:

  • The elevation points along the creek centre line of the north tributary;
  • The elevation points along a road crest located at the east of the model domain; and
  • A polygon that defines an area with a uniform elevation.

You will note that we haven’t copied across the Land_Fill.shp file. This is because the .\TUFLOWFV\model\gis\ folder is reserved for model files that will be directly read by the model in TUFLOWFV format. We will convert Land_Fill.shp to the correct format later in the tutorial.

Tute 3 advanced GIS 005.png

6. To display elevation labels for each for the points, first double click the 2d_zln_Gully_Breakline_001_P layer to bring up the layer properties menu.

  • In the “Labels” tab, select “Single labels” from the first drag down list,
  • Select the “Elevation” attribute from the “Label with” drag down list,

Tute 3 advanced GIS 006.png

  • Press OK and repeat for the 2d_zln_Road_Breakline_001_P layer to review the labelled elevation points.

Tute 3 advanced GIS 007.png

Assign data to TUFLOW FV empty layers

The 2d_zln_Road_Breakline_001_P.shp and 2d_zln_Gully_Breakline_001_P.shp files are already prepared in the correct TUFLOW FV input format and thus were ok to copy into our .\TUFLOWFV\model\gis folder. However, these files only depict elevation points as indicated by the “_P” suffix on the filenames. In order to run our TUFLOW FV model we will require breakline polyline geometry GIS layers as well as these point files.

1. We already have elevation points that define key locations on our roads and channel. What we need to do now is connect these points to provide a continuous breakline by using polyline gis features. To do this we will import an empty 2d_zln polyline layer using the Import Empty file tool.

Tute 1 GIS integration 026.png

  • Select the type 2d_zln
  • Give the Run ID as Road_Breakline_001
  • Check Lines as the geometry type and press OK

Tute 3 advanced GIS 008.png

2. A 2d_zln polyline must be “snapped” to the points to connect them. If the points aren’t snapped correctly then TUFLOW FV will throw an error on startup. To snap, first ensure that the snapping toolbar is visible. Right click on the toolbar and check the Snapping Toolbar box.

Tute 3 advanced GIS 009.png

  • Then, enable snapping by clicking on Tute 3 QGIS snap icon1.PNG, followed by the Tute 3 QGIS snap icon2.PNG button to open snapping options,

Tute 3 advanced GIS 012.png

  • Select “Advanced Configuration” from the second drop down list and check the 2d_zln_Road_Breakline_001_P.shp layer,

Tute 3 advanced GIS 014.png

  • Now select the 2d_zln_Road_Breakline_001_L layer and toggle editing QGIS toggle editing icon.png,
  • Using the Add Feature tool QGIS add feature icon.png, click and snap onto each elevation point to create a polyline. Note that a pink square appears when the mouse is “snapped” to a point.

Tute 3 advanced GIS 015.png

  • Right click to finish editing. Leave the Elevation attribute as NULL since the elevations along the line are assigned to the line by linearly interpolating locations between those points. i.e. the polyline Z attribute in this case is ignored.

3. Finish and save your edits by toggling off the editing button.

4. Repeat steps 1-3 for the gully breakline. Use the Import Empty file to import another template 2d_zln polyline layer.

  • Select the type 2d_zln,
  • Give the Run ID as Gully_Breakline_001,
  • Check Lines as the geometry type and press OK,
  • Enable snapping for the 2d_zln_Gully_Breakline_001_P.shp layer under the Snapping Options menu.
  • Toggle editing 2d_zln_Gully_Breakline_001_P.shp layer and connect those points one by one using the add line feature tool.

Tute 3 advanced GIS 016.png

  • Also leave the Elevation attribute as NULL and finish/save the edit by toggling off editing.

5. The last GIS file contains a pre-prepared polygon but it does not have any attributes. This time we are going to copy the polygon into a new empty 2d_zln region file and update the elevation attribute. Use the Import Empty file to import a template 2d_zln region layer.

Tute 1 GIS integration 026.png

  • Select the type 2d_zln,
  • Give the Run ID as Fill_Pad_001,
  • Check Regions as the geometry type and press OK.

Tute 3 advanced GIS 017.png

6. Toggle editing QGIS toggle editing icon.png, for the 2d_zln_Fill_Pad_001_R layer and select the Land_Fill layer in the Layer Panel.

  • Click the Select Feature button Tute 3 advanced GIS 018.png and drag to select the polygon in the Land_Fill layer. The polygon turns yellow if it is successfully selected.

Tute 3 advanced GIS 019.png

  • Use Ctrl + C to copy the polygon, then select the 2d_zln_Fill_Pad_001_R layer from the Layer Panel and use Ctrl + V to paste the polygon. Make sure you receive a message “1 features were successfully pasted.”

Tute 3 advanced GIS 020.png

  • Use the Identify Feature tool and click the polygon to open a Feature Attributes Window. Update the attributes by clicking “Edit feature form”:

Tute 3 advanced GIS 021.png

  • Set the Elevation attribute to 6, this will specify a uniform elevation of 6 m inside the polygon.

Tute 3 advanced GIS 022.png

7. Finish the edit by toggling off the editing button and when prompted, save the file.

8. Remove the Land Fill shape file from your workspace as we no longer need it.

FVC Updates

1. Now we are going to replace the original csv-based topographic update layers with GIS commands. Please comment out the original geometry commands in FMA2_Hydro_002_GIS.fvc as shown below:

!Cell elevation polyline == ..\model\csv\Gully_Breakline_002_ptp.
!Cell elevation polyline == ..\model\csv\Road_Breakline_002_ptp.csv
!Cell elevation polygon == ..\model\csv\Fill_Pad_002_ptp.csv, 6.0

2. Add commands to read the breaklines and points. Use vertical bars “|” to read two files in one command:

Read GIS Z Line  == ..\model\gis\2d_zln_Gully_Breakline_001_L.shp | ..\model\gis\2d_zln_Gully_Breakline_001_P.shp 
Read GIS Z Line  == ..\model\gis\2d_zln_Road_Breakline_001_L.shp | ..\model\gis\2d_zln_Road_Breakline_001_P.shp 

3. Use the same command to read the polygon:

Read GIS Z Line  == ..\model\gis\2d_zln_Fill_Pad_001_R.shp

Now the geometry commands block looks like this:

Tute 3 advanced GIS 023.png

4. In the output commands block, also add:

Write Check Files  == ..\check

5. You have now updated your fvc file and included the relevant GIS and check commands. Please now update your batch file as shown below to include the latest run and run the model (for additional support with running from a batch file please refer to Running from a Batch File):

%exe% FMA2_Hydro_002_GIS.fvc

Review of Results and Discussion

1. Double click to open FMA2_Hydro_002_GIS.qgs workspace from the \runs\log directory, and apply the default TUFLOW style to all layers.

Tute 1 GIS integration 014.png

2. Double click the FMA2_Hydro_002_GIS_mesh_check_R layer to render the mesh based on “ZB” attribute:

  • In the “Symbology” tab, select “Graduated” from the first drag down list
  • Select “ZB” attribute from the Column drag down list

Tute 3 advanced GIS 024.png

  • Click “Change” button and select “Simple fill”. Change the “Fill style” to “Solid” if it hasn’t been selected

Tute 3 advanced GIS 025.png

  • Select “Spectral” from the Color ramp drop down list, followed by “Invert Color Ramp” and then click “Classify”,

Tute 3 advanced GIS 026.png

  • Adjust the value ranges by double clicking on the symbols,

Tute 3 advanced GIS 027.png

  • Press OK and check if the mesh elevation specified by the ASC grid look reasonable.

Tute 3 advanced GIS 028.png

3. Also check the _zln_zpt_check_P file and apply TUFLOW Style (refer to step 1) to observe which cells have been raised/lowered by the polylines and the polygon,

Tute 3 advanced GIS 029.png

Congratulations, you are now well on your way to integrating GIS topography with TUFLOW FV.

Set Nodestrings for Structures

Next, we will also set the structure nodestrings using GIS files instead of using CSV files.

Update Input Files

1. Open TUFLOWFV\model\gis\2d_ns_Struct_001_L.shp (as copied in Section 4.3) in QGIS if it hasn’t already been opened and apply TUFLOW Style (refer to Apply TUFLOW Style). This file includes single nodestrings to present a weir and a bridge, and a coupled nodestrings to represent the inlet and the outlet of a culvert.

Tute 3 advanced GIS 030.png


2. Save FMA2_Hydro_002_GIS.fvc as FMA2_Hydro_003_GIS.fvc and open this file in Notepad++. 3. Comment out the original CSV nodestring commands:

!nodestring polyline == ..\model\geo\STRUCT\FMA2_Struct_Nodestring_002.csv, 5
!nodestring polyline == ..\model\geo\STRUCT\FMA2_Struct_Nodestring_002.csv, 6
!nodestring polyline == ..\model\geo\STRUCT\FMA2_Struct_Nodestring_002.csv, 7
!nodestring polyline == ..\model\geo\STRUCT\FMA2_Struct_Nodestring_002.csv, 8

4. Add the following command to read the nodestrings from the GIS file:

Read GIS Nodestring  == ..\model\gis\2d_ns_Struct_001_L.shp

5. Update the batch file with FMA2_Hydro_003_GIS.fvc and run the model.

Discussions

Double click to open workspace \runs\log\FMA2_Hydro_003_GIS.qgs and apply the default TUFLOW style to all layers (refer to Apply TUFLOW Style). Check the _ns_check_L file for how cell sides are selected by nodestings. Note that GIS nodestrings do not need to always snap to the cell vertexes as TUFLOW FV will determine the closest cell faces for you. This check file is important to ensure that your GIS specified external nodestrings have been applied as you intended.

Tute 3 advanced GIS 031.png

Conclusion

Thank you for completing the Advanced GIS integration component of Tutorial Model 03 . Please return to Tutorial Model 03 to complete the remainder of the tutorial.

We will continue to add more functionality over time so please periodically review. If you wish to keep up to date with all things TUFLOW and TUFLOW FV then please join our LinkedIn group here: https://www.linkedin.com/groups/1908583 If you have any further queries, feedback or requests for new functionality please feel free to get in contact with support@tuflow.com