Apply Math Formula to Grids

Use the Apply a Math Formula to Grids dialog (GRIDCALC GX) to apply an expression to grid files. Expressions work on a grid point-by-point basis.

Apply a Math Formula to Grids dialog options

Grid file G1

Grid file name of the variable G1. G1 is required.

Script Parameter: GRIDCALC.G1

G2

Grid file name of the variable G2.

Script Parameter: GRIDCALC.G2

G3

Grid file name of the variable G3.

Script Parameter: GRIDCALC.G3

G4

Grid file name of the variable G4.

Script Parameter: GRIDCALC.G4

G5

Grid file name of the variable G5.

Script Parameter: GRIDCALC.G5

G6

Grid file name of the variable G6.

Script Parameter: GRIDCALC.G6

Expression

The expression

Script Parameter: GRIDCALC.EXP

OR expression file

OR name of an expression file (.EXP).

Script Parameter: GRIDCALC.FILE

Application Notes

Grid file 1 is required. If grids G2 to G6 do not exist, they will be created based on the grid G1.

If an expression file is specified, it will be read as the expression and any expression that was defined will be ignored. Each line of the expression file will be concatenated to form the expression. The maximum expression length is 1023 characters.

For example, to add two grids the expression would be "G3=G1+G2;"

On-the-fly reprojection of grids

If the input grids do not match in coordinate system, grid size or cell size, they will be sampled to match the G1 grid and the result grid will be spatially equivalent to G1. If the output grid does not already exist, it also takes on the coordinate system, grid size and cell size of the G1 grid. If the output grid already exists, then it must have the same coordinate system, grid size and cell size as the G1 grid, or the following error message will appear, and the operation will fail:

Error writing to an image that is being reprojected. This error may be the result of using the GRIDCALC GX incorrectly. It is recommended that the output grid (if it already exists) be the "G1" grid, because all other grids are automatically re-projected to match its location, cell size, projection etc. See the documentation for more information.

This occurs because the grid expression calculation engine will not alter the coordinate system, grid size or cell size of an existing grid; it will only alter grid values at existing G1 grid locations. One or more of the G2, G3, G4 etc. grids must have been used as the output grid, and does not exactly match the grid locations in G1.