There are several tools in RAS Mapper that allow the user to evaluate model results at specific locations through interactive point querying and with profile lines.   However, in order to perform analysis of the entire layer, you can use the the RASter Calculator.  The RASter Calculator allows you to perform mathematical and logical operations on gridded datasets in RAS Mapper through user-defined scripts.  When using the RASter Calculator, the you are actually creating a syntax for a Calculated Layer that can then be evaluated in RAS Mapper using the interactive querying tools used for evaluating normal RAS Results.  The Calculated Layer is intended to be treated very similarly to a Dynamic Map, in that you can animate the layer.  If you are using the calculated layer to compare results from two different HEC-RAS simulations then it is quite convenient to  use the animate toolbar to evaluate various timesteps.   However, a calculated layer can also have a static component layer, such as the Terrain layer or using the value from a particular timestep in a result.

A Calculated Layer is added to RAS Mapper by selecting a RAS Result group or by selecting the Map Layers group, right clicking and choosing the Create a New Calculated Layer menu item.

Overview

A Calculated Layer is created by defined the Layers you want to use in the analysis.  By default, the Terrain layers will always be available to the user.  After defining the layers (think of them as variables in an equation), you can then write simple code to perform and operation. The intent, is to have example scripts provided with HEC-RAS, so that the user doesn't have to create a script.  One example script might be to compare water surface elevations from two different plans.  The basic steps to creating a calculated layer are listed below.

Begin with Tools | Create Calculated Layer menu item or right-click on a Plan and select Create a New Calculated Layer.

  1.  Select an example Script or "User Defined" to write your own.
  2.  Add the Layers to be evaluated.
  3.  Add mathematical operations and logic calculation code.
  4.  Provide an output location to save the script.
  5.  Provide a Name for the Calculated layer.
  6.  Press the Create Layer button to add the layer to RAS Mapper.

 

Scripts

The RASter Calculator was developed to allow users to write complex scripts; however, HEC-RAS provides example scripts to assist you in performing common calculations.  Example scripts are available from the Script list at the top of the calculator.  Current examples include:

  • Compare WSE - Allows the comparison of water surface profiles from two different plans.  By default, the script uses the first two Plans available in the RAS project.
  • Depth * Velocity - Result is the multiplication of the Depth times the Velocity for the first plan in the RAS Project.  Using the Max profile is not appropriate as it multiplies the max depth and max velocity (which will not have occurred at the same time).
  • Hazard - This is an complex example of how to script to evaluated the product of depth and velocity given rule criteria.

You can Load a script shared by another RAS user or Save a script once you have completed it.  Example scripts most likely will not be exactly what you need. To write or modify the code, you will first need to add Layers or change what the represent.

Layer Variables

Layers are used as the "variables" for scripting.  Tools are available to Add New, Delete, Rename, and Edit.  By default, Terrain layers are added as static layers that cannot be modified or removed.

Variable names can contain letters and numbers.  Variable names may NOT start with a number.


Add - Use the Add button to add a Layer to be evaluated.  When a layer is added, you must define how the layer will be use.  A layer variable is defined by its Name, Plan, Map Type, Animation Behavior, and Profile.

  • Name - a short name for the layer (variable).
  • Plan - identifies the RAS Plan (result) that the map layer is generated from.
  • Map Type - this defines the simulation result of interest (Water Surface Elevation, Velocity, etc.).
  • Animation Behavior - defines whether the layer can be animated by time step (profile) or if the layer is static (does not change the profile).
  • Profile - the water surface profile to be evaluated. Only available for Static layers.

Once a layer definition has been supplied, click the Add Variable button to add to the Layer list.  Press the Close button to dismiss the form.

Delete - Removes the selected Layer from the Layer list.

Rename - Allows you to rename the selected Layer variable.

Edit - Allows you to change the definition of a the selected layer variable.

Raster Layer Variables

Raster Layers are used as the "variables" for raster data that are stored on disk.  You can load data (such as TIFFs) to use in performing a raster calculation. This is convenient for performing analysis with datasets that are not HEC-RAS Results.  For instance, identify areas of a specified land cover type that are also inundated based on the HEC-RAS Depth result.

Calculation Code

Scripts are written in a simple text editor using either Visual Basic or C#.  You are only writing the functional code (not the complete program).  Once a script is complete, it will be compiled at runtime when the Calculated Layer is evaluated.  Example code is provided to assist users in scripting.  More complete help is available by clicking on the  Help button.

To check to see if it will compile use the Check Code to verify that the script will compile.  Use the View Full Code button to see the full code and visually inspect lines of code that may have errors.  Successful code compilation will result in a window message without errors.  If there are errors, the line number where an error occurred will be reported at the top of the Code Compiler Check window.

Help

Help is available by clicking on the  Help button.  Help is provided for the coding in Visual Basic logic and .Net Framework math functions.  Additionally, example scripts are provided to demonstrate the use of functional code.  The example code can be copied and pasted into the coding window, however, layer variables will have to be created to use the script.  Examples of available help are shown below.

Calculated Layer

Once a script is finished, specify a Folder location to store the map script (name.rasscript) and provide a layer Name.  The script will be saved to disk will be used to load the map each time RAS Mapper is opened.  Clicking the Create Layer button will then add the Calculated Layer to the Map.

If a script already exists on disk, you will be prompted for a unique name.

Once a Calculated Layer has been added to the Map, it will be treated like other layers.  All the fundamental map querying tools will be available to analyze the layer.  If the layer variables were added as a dynamic map type, the animation toolbar will allow for changing the profile.