Map and Table Calculation

IFUNDEF( ) function

If a is undefined, then return b, else return a.
If a is undefined, then return b, else return c.

Syntax

IFUNDEF(a, b)
IFUNDEF(a, b, c)

Input

a is the test condition: a boolean expression containing at least one map name or one column name.
b, c an expression containing at least one map name or one column name, or simply a value, class name, ID, etc.

Output

IFUNDEF returns: if a is undefined, b is returned;
if a is not undefined and c is specified, c is returned;
if a is not undefined and c is not specified, a is returned.
Domain:

system domain Value;

the class/ID domain returned by c;

if c returns a string or undefined value, the class/ID domain returned by b;

if both b and c return a string, no default output domain;

if c is not specified and b returns a string or undefined value, the class/ID domain of a.

Notes:

Tip:

When the definition symbol = is used, a dependent output map or dependent output column is created; when the assignment symbol := is used, the dependency link is immediately broken after the output map/column has been calculated.

Usable in

MapCalc, TabCalc

Examples

MapCalc example using a value map:

OutMap = IFUNDEF(DEM,1000)

OutMap = IFUNDEF(DEM,1000,DEM)

 

InMap

OutMap

300 ? 400
? 100 ?
500 200 600
300 1000 400
1000 100 1000
500 200 600

 

Note: The following expression will give the same result:
OutMap = IFF(ISUNDEF(DEM),1000,DEM)

MapCalc example using a class map:

OutMap = IFUNDEF (Landuse,"Mountains")

OutMap = IFUNDEF(Landuse,"Mountains",Landuse)

Landuse

OutMap

? F G
L L ?
G ? F
M F G
L L M
G M F

In OutMap, class name "Mountains" (i.e. M) is assigned for every undefined pixel in map Landuse. To all other pixels, the original class name is assigned (F=Forest, G=Grassland, L=Lake).

 

Note: The following expression will give the same result:
OutMap = IFF(ISUNDEF(Landuse),"Mountains",Landuse)

TabCalc examples:

OutCol1 = IFUNDEF(Population,0)

OutCol1 = IFUNDEF(Population,0,Population)

OutCol2 = IFF(ISUNDEF(Landuse),"Mountains")

OutCol2 = IFF(ISUNDEF(Landuse),"Mountains",Landuse)

 

Sitenr

Population

Landuse

OutCol1

OutCol2

1

850

Crops

850

Crops

2

?

Grassland

0

Grassland

3

600

Urban area

600

Urban area

4

950

?

950

Mountains

5

1250

Crops

1250

Crops

6

450

?

450

Mountains

7

?

Grassland

0

Grassland

8

900

Urban area

900

Urban area

 

See also:

ISUNDEF
IFNOTUNDEF
IFF
Map and Table Calculation : Assigning undefined values
How to calculate with undefineds in maps and tables
Map and Table Calculation : Merging domains (workaround)