RiverTools Grid (RTG) Format

RiverTools Grid (RTG) are binary files with no header that store a 2D array (or grid) whose size is the same size as the DEM (*_DEM.rtg) they were derived from. Their dimensions, georeferencing and other information are identical to the DEM, except possibly for their data type. Values in the file are stored in row major order; that is, values for the first (north) row are followed by values for the second row, and so on. The filesize for an RTG file is always equal to the following product:

filesize = (ncols x nrows x BPE)

where BPE is the number of Bytes Per Element in the 2D array. The possible data types for an RTG file are BYTE, INTEGER, LONG, FLOAT, DOUBLE, LONG64, UINT, ULONG and ULONG64. The corresponding values of BPE are 1, 2, 4, 4, 8, 8, 2, 4 and 8. Each RTG file has a data type that is appropriate for the range of possible values that array can contain. This use of the most "economical" data type results in more efficient use of disk space and faster access times.

Given the number of rows and columns in the DEM (nrows and ncols), the data type of an RTG file can often be deduced from its filesize. A notable exception is when BPE is equal to 4. In this case, the data type could be either LONG or FLOAT, and additional information is required in order to determine which one. A standard, recognized filename extension is one method for deciding between these two data types. There is also a text file called lon_list.txt in the RiverTools resource folder that contains filename extensions for RTG files that have the (less common) LONG data type. For example, this list includes the extension: "_mask.rtg". You can add other extensions to this file as necessary.

Beginning in RiverTools 4.0, any RTG file can have its own RTI file where the filename is identical except for replacing ".rtg" with ".rti". If present, this file is always examined first to determine the data type. Some of the extraction routines that produce RTG files also produce a matching RTI file.

Routines in the Extract menu create RTG files from other RTG files, such as the initial DEM (*_DEM.rtg). For example, the Extract → Flow Grid dialog will create a copy of the DEM with the extension _rawDEM.rtg which it will leave unaltered, and will then fill depressions in the file with extension _DEM.rtg. This routine will then go on to create a D8 flow grid with extension _flow.rtg from the depressionless DEM grid. This D8 flow grid is then used by other routines in the Extract menu to create additional RTG files. For example, the following table shows some of the more commonly used RTG files.

Attribute File Extension Data Type
Elevation (depression-filled) "_DEM.rtg" any type
D8 Area "_area.rtg" or "_d8-area.rtg" FLOAT or LONG
D8 Flow Angle "_d8-angle.rtg" FLOAT or DOUBLE
D8 Curvature "_d8-curv.rtg" FLOAT
D8 Flow Codes "_flow.rtg" BYTE
D8 Flow Distance "_FD.rtg" or "_d8-flowdist.rtg" FLOAT
D8 Number of "Kids" "_nkids.rtg" or "_d8-nkids.rtg" BYTE
D8 Slope (local, cell-to-cell) "_slope.rtg" or "_d8-slope.rtg" FLOAT
D-Infinity Flow Angle "_dinf-angle.rtg" FLOAT or DOUBLE
D-Infinity Area "_dinf-area.rtg" FLOAT or DOUBLE
D-Infinity Slope "_dinf-slope.rtg" DOUBLE
Imposed gradient DEM "_imposed_DEM.rtg" FLOAT
MFM Flow Angle * "_mf-angle.rtg" FLOAT or DOUBLE
MFM Total Contributing Area * "_mf-area.rtg" FLOAT or DOUBLE
MFM Specific Contributing Area * "_mf-sarea.rtg" FLOAT or DOUBLE
Horton-Strahler Stream Order (D8) "_order.rtg" BYTE
Raw Elevations (with depressions) "_rawDEM.rtg" any type
Watershed units "_sides.rtg" LONG
Topographic index "_TI.rtg" FLOAT
Pit basin mask "_pitbasins_mask.rtg" LONG

* Note: MFM stands for the Rivix Mass Flux Method.

There are several RiverTools commands that can be used for working with RTG files. These require access to the IDL command line, which is available with the RiverTools+IDL combination but not with RiverTools itself. These include:

  • RT_Read_Grid
  • RT_Check_Grid_Type
  • RT_Read_Subgrid
  • RT_Write_Subgrid
  • RT_Read_RTM_As_Grid
  • RT_Get_Available_DEMs
  • RT_Get_Available_Grids

These are fully documented in the RiverTools Command Reference. The Extract menu also provides access to many routines for creating RTG files.

Copyright (C) RIVIX, LLC. 1998-2021