Module Grid Calculator
The Grid Calculator calculates a new grid based on existing grids and a mathematical formula. The grid variables are single characters which correspond in alphabetical order to the grid list order ('a' = first grid, 'b' = second grid, ...)
Alternatively you can address with letter 'g' followed by position index (g1, g2, g3, ...). Grids from other systems are addressed similarly, just using letter 'h' (h1, h2, h3, ...)
Examples:
using letters: sin(a) * b + c
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
sqrt(x) - square root
ln(x) - natural logarithm
log(x) - base 10 logarithm
exp(x) - exponential
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) - if x>y the result is 1.0, else 0.0
lt(x, y) - if x<y the result is 1.0, else 0.0
eq(x, y) - if x=y the result is 1.0, else 0.0
mod(x, y) - returns the floating point remainder of x/y
ifelse(c, x, y) - if c=1 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 | 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>] [-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)
-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