Map and Table Calculation

General syntax

Introduction

To calculate with raster maps, you can use the command line of the Main window; to calculate with columns in a table, you can use the command line of a table window.

A MapCalc or TabCalc formula consists of:

MapCalc syntax

OutputMap  = Expression
OutputMap := Expression

TabCalc syntax

OutputColumn  = Expression
OutputColumn := Expression

 

Notes:

Examples

MapCalc example

A simple MapCalc formula reads:

OutMap = InMapA + InMapB

 

InMapA

InMapB

OutMap

1 2 3
4 5 6
7 8 9
10 20 30
40 50 60
70 80 90
11 22 33
44 55 66
77 88 99

 

The values of the pixels in OutMap are the sums of the values in the corresponding pixels of InMapA and InMapB.

TabCalc example

A simple TabCalc formula reads:

OutColumn = InColumnA + InColumnB

In the table, this looks as follows:

 

InColumnA

InColumnB

OutColumn

1

10

11

2

20

22

3

30

33

4

40

44

Each record in column OutColumn stores the sum of the values of the records in InColumnA and InColumnB.

Names of maps and tables

In ILWIS 3, object names, i.e. input or output map or table names, comply with Windows long file names.

Furthermore, it is not allowed to use % in any ILWIS object name.

However, on the command line, object names must be enclosed by single quotes when the object name:

Object extensions should be left outside the quotes. When an object name already contains a single quote, this single quote must be duplicated.

Thus, on the command line, single quotes around object names can only be omitted when object names start with a character between A to Z and do not contain spaces nor special characters.

Note:

When an existing output map name is specified, a message box will appear asking whether to overwrite the existing map or not.

For more information and examples, see How to use long object names.

Definition symbol =     Assignment symbol :=

By using the defintion symbol =, a dependent output map or a dependent output column will be created.

A dependent map or a dependent column has the following advantageous characteristics:

You can manage dependent maps and columns through:

For more information, refer to Basic concepts : dependent data objects.

 

Tip: To make all columns in a table up-to-date, you can also click the Update all columns button in the toolbar of a table window.

By using the assignment symbol :=, an editable map or column will be created. Dependency links are immediately broken after the output map or the output column has been calculated.

 

Note: It does not matter whether you type spaces around the definition or assignment symbol, or in the expression or not.

Expression

The expression usually contains one or more input map names or column names combined with operators and/or functions to specify what calculation has to be performed. The operators and functions which can be used in Table Calculations are identical to those in Map Calculation.

For overviews of operators and functions, see:

 

Examples of the usage of a function are presented in the topic on the function.

Furthermore, advanced users may wish to create their own functions. For more information, see Map and Table Calculation : User-defined functions.

Notes:

Tip:

It is advised to use built-in functions instead of creating a combination of simple functions which perform the same calculation because pre-defined functions are quicker.

Miscellaneous

General information on the command lines:

Raster Map Definition dialog box:

After typing a MapCalc formula on the command line of the Main window, and pressing Enter, the Raster Map Definition dialog box will appear, in which you can:

Normally, ILWIS will come up with correct defaults for domain, value range and precision.

Column Properties dialog box:

After typing a TabCalc formula on the command line of a table window, and pressing Enter, the Column Properties dialog box will appear, in which you can:

Normally, ILWIS will come up with correct defaults for domain, value range and precision.

Overruling the default domain, value range and precision:

Generally, ILWIS will use correct defaults for the domain and possible value range and precision of the output map(s) or columns. When using the Raster Map Definition dialog box or the Column Properties dialog box, you will notice this. In scripts however, these dialog boxes will never appear.

To ensure that an output map or column will use a certain domain, and/or a certain value range and/or a certain precision, you can specify this yourself within a pair of curly brackets {} after the output map/column name.

Within the curly brackets, you can specify:

When you specify both domain and value range, separate these with a semicolon.

Notes:

Examples

OUT1{dom=MyVal} = expression

OUT2{dom=MyVal;vr=0:10000:1} = expression

OUT3{dom=MyVal;vr=0:10000} = expression

OUT4{dom=MyVal;vr=::0.001} = expression

 

Tip: For more information and examples, see Appendices : Construction of expressions.

See also: