Tool Field Calculator
The table calculator calculates a new attribute from existing attributes based on a mathematical formula. Attributes are addressed by the character 'f' (for 'field') followed by the field number (i.e.: f1, f2, ..., fn) or by the field name in square brackets (e.g.: [Field Name]).
Examples:
- sin(f1) * f2 + f3
- [Population] / [Area]
One can also use the drop-down-menu to append fields numbers to the formula.
If the use no-data flag is unchecked and a no-data value appears in a record's input, no calculation is performed for it and the result is set to no-data.
Following operators are available for the formula definition:
+ | Addition |
- | Subtraction |
* | Multiplication |
/ | Division |
abs(x) | Absolute Value |
mod(x, y) | Returns the floating point remainder of x/y |
int(x) | Returns the integer part of floating point value x |
sqr(x) | Square |
sqrt(x) | Square Root |
exp(x) | Exponential |
pow(x, y) | Returns x raised to the power of y |
x ^ y | Returns x raised to the power of y |
ln(x) | Natural Logarithm |
log(x) | Base 10 Logarithm |
pi() | Returns the value of Pi |
sin(x) | Sine, expects radians |
cos(x) | Cosine, expects radians |
tan(x) | Tangent, expects radians |
asin(x) | Arcsine, returns radians |
acos(x) | Arccosine, returns radians |
atan(x) | Arctangent, returns radians |
atan2(x, y) | Arctangent of x/y, returns radians |
min(x, y) | Returns the minimum of values x and y |
max(x, y) | Returns the maximum of values x and y |
gt(x, y) | Returns true (1), if x is greater than y, else false (0) |
x > y | Returns true (1), if x is greater than y, else false (0) |
lt(x, y) | Returns true (1), if x is less than y, else false (0) |
x < y | Returns true (1), if x is less than y, else false (0) |
eq(x, y) | Returns true (1), if x equals y, else false (0) |
x = y | Returns true (1), if x equals y, else false (0) |
and(x, y) | Returns true (1), if both x and y are true (i.e. not 0) |
or(x, y) | Returns true (1), if at least one of both x and y is true (i.e. not 0) |
ifelse(c, x, y) | Returns x, if condition c is true (i.e. not 0), else y |
rand_u(x, y) | Random number, uniform distribution with minimum x and maximum y |
rand_g(x, y) | Random number, Gaussian distribution with mean x and standard deviation y |
nodata() | Returns tables's no-data value |
isnodata(x) | Returns true (1), if x is a no-data value, else false (0) |
- Author: V.Olaya (c) 2004, O.Conrad (c) 2011, J.Spitzmueller, scilands GmbH (c) 2022
- Menu: Table|Calculus
Parameters
Name | Type | Identifier | Description | Constraints | |
---|---|---|---|---|---|
Input | Table | Table, input | TABLE | - | - |
Output | Result (*) | Table, output, optional | RESULT | - | - |
Options | Result Field (*) | Table field | FIELD | Select a field for the results. If not set a new field for the results will be added. | - |
Field Name | Text | NAME | - | Default: Calculation | |
Formula | Text | FORMULA | - | Default: f1 + f2 | |
Add Field to Formula | Choice, GUI | FIELD_SELECTOR | Convenient way to append a field number to the formula. Shows one all numeric fields with number, name and datatype overview. | Available Choices: Default: 0 | |
Selection | Boolean | SELECTION | - | Default: 1 | |
Use No-Data | Boolean | USE_NODATA | - | Default: 0 | |
(*) optional |
Command-line
Usage: saga_cmd table_calculus 1 [-TABLE <str>] [-RESULT <str>] [-FIELD <str>] [-NAME <str>] [-FORMULA <str>] [-SELECTION <str>] [-USE_NODATA <str>] -TABLE:<str> Table Table, input -RESULT:<str> Result Table, output, optional -FIELD:<str> Result Field Table field -NAME:<str> Field Name Text Default: Calculation -FORMULA:<str> Formula Text Default: f1 + f2 -SELECTION:<str> Selection Boolean Default: 1 -USE_NODATA:<str> Use No-Data Boolean Default: 0