How to calculate

with class names or IDs in maps and tables

When using class names or IDs in a MapCalc or TabCalc expression, these class names or IDs should be put "between double quotes".

For example, if you want to assign a 1 in a new map Result to all areas of map Landuse where there is Coffee, and a 0 to all other landuse classes, you can use the following formula:

Result = Landuse = "Coffee"

   

Landuse:

Result:

Read in the Landuse map for B= Bare, for C= Coffee, and for S= Shrub.

The same formula can be used in Table calculation when you want to assign a 1 to all fields in column Landuse where the landuse class is Coffee.

   

Parcel

Landuse

Result

01256

Coffee

1

01257

Banana

0

01258

Rice

0

01259

Maize

0

01260

Coffee

1

01261

Maize

0

 

Note: Result=IFF(Landuse="Coffee",1,0) produces the same result but is longer and slower.

See also: