Module Grid Calculator
The Grid Calculator calculates a new grid based on existing grids and a mathematical formula. The grid variables in the formula begin with the letter 'g' followed by a position index, which corresponds to the order of the grids in the input grid list (i.e.: g1, g2, g3, ... correspond to the first, second, third, ... grid in list). Grids from other systems than the default one can be addressed likewise using the letter 'h' (h1, h2, h3, ...), which correspond to the 'Grids from different Systems' list.
Example: sin(g1) * g2 + h1
the same using indices: sin(g1) * g2 + g3
The following operators are available for the formula definition:
+ Addition
- Subtraction
* Multiplication
/ Division
^ power
abs(x) - absolute value
sqr(x) - square
sqrt(x) - square root
ln(x) - natural logarithm
log(x) - base 10 logarithm
exp(x) - exponential
pow(x, y) - power with mantisse x and exponent y
sin(x) - sine
cos(x) - cosine
tan(x) - tangent
asin(x) - arcsine
acos(x) - arccosine
atan(x) - arctangent
atan2(x, y) - arctangent of x/y
gt(x, y) - the result is 1.0, if x is greater than y else 0.0
x > y - the result is 1.0, if x is greater than y else 0.0
lt(x, y) - the result is 1.0, if x is less than y, else 0.0
x < y - the result is 1.0, if x is less than y, else 0.0
eq(x, y) - the result is 1.0, if x equals y, else 0.0
x = y - the result is 1.0, if x equals y, else 0.0
mod(x, y) - returns the floating point remainder of x/y
ifelse(c, x, y) - if condition c is not 0.0 the result is x, else y
int(x) - integer part of floating point value x
pi() - returns the value of Pi
xpos(), ypos() - get the x/y coordinates of the current cell
row(), col() - get the current cell's column/row index
- Author: A.Ringeler (c) 2003
- Specification: grid
- Menu: Grid|Calculus
Parameters
| Name | Type | Identifier | Description | Constraints |
Input | Grids (*) | Grid list (optional input) | GRIDS | in the formula these grids are addressed in order of the list as 'g1, g2, g3, ...' | - |
Grids from different Systems (*) | Grid list (optional input) | XGRIDS | in the formula these grids are addressed in order of the list as 'h1, h2, h3, ...' | - |
Output | Result | Grid (output) | RESULT | - | - |
Options | Interpolation | Choice | INTERPOLATION | - | Available Choices: [0] Nearest Neighbor [1] Bilinear Interpolation [2] Inverse Distance Interpolation [3] Bicubic Spline Interpolation [4] B-Spline Interpolation Default: 4 |
Formula | Text | FORMULA | - | Default: (g1 - g2) / (g1 + g2) |
Name | Text | NAME | - | Default: Calculation |
Take Formula | Boolean | FNAME | - | Default: 0 |
Use NoData | Boolean | USE_NODATA | Check this in order to include NoData cells in the calculation. | Default: 0 |
Data Type | Choice | TYPE | - | Available Choices: [0] bit [1] unsigned 1 byte integer [2] signed 1 byte integer [3] unsigned 2 byte integer [4] signed 2 byte integer [5] unsigned 4 byte integer [6] signed 4 byte integer [7] 4 byte floating point number [8] 8 byte floating point number Default: 7 |
(*) optional |
Command-line
Usage: saga_cmd grid_calculus 1 [-GRIDS <str>] [-XGRIDS <str>] [-INTERPOLATION <str>] [-RESULT <str>] [-FORMULA <str>] [-NAME <str>] [-FNAME <str>] [-USE_NODATA <str>] [-TYPE <str>]
-GRIDS:<str> Grids
Grid list (optional input)
-XGRIDS:<str> Grids from different Systems
Grid list (optional input)
-INTERPOLATION:<str> Interpolation
Choice
Available Choices:
[0] Nearest Neighbor
[1] Bilinear Interpolation
[2] Inverse Distance Interpolation
[3] Bicubic Spline Interpolation
[4] B-Spline Interpolation
Default: 4
-RESULT:<str> Result
Grid (output)
-FORMULA:<str> Formula
Text
Default: (g1 - g2) / (g1 + g2)
-NAME:<str> Name
Text
Default: Calculation
-FNAME:<str> Take Formula
Boolean
Default: 0
-USE_NODATA:<str> Use NoData
Boolean
Default: 0
-TYPE:<str> Data Type
Choice
Available Choices:
[0] bit
[1] unsigned 1 byte integer
[2] signed 1 byte integer
[3] unsigned 2 byte integer
[4] signed 2 byte integer
[5] unsigned 4 byte integer
[6] signed 4 byte integer
[7] 4 byte floating point number
[8] 8 byte floating point number
Default: 7