RTG File Format (RiverTools Grid)

RiverTools Grid (RTG) are binary files with no header that store a 2D array (or grid) whose dimensions and georeferencing are same as the DEM (*_DEM.rtg) they were derived from. They may, however, have a different data type than the associated DEM. 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, and DOUBLE. The corresponding values of BPE are 1, 2, 4, 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. Georeferencing information associated with an RTG file is stored in a plain text file in the RTI file format.

Given the number of rows and columns in the DEM (nrows and ncols), the data type of an RTG file can be deduced from its filesize in all cases except 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.