### Formula-based Calculation

Formula-based Calculation allows you to operate math, multivariate and neigbourhood functions on one or multiple grids. It also allows you to make queries (using the 'if-then-else' function). In fact all the functions from PCRaster can be used in this modeltype. For a description of the PCRaster functions we advise you to look in the PCRaster Manual.

You can add this modeltype with right click at a composite model or project and select 'Add Model' and the select the Formula Based Function. Learn more about how to add models. To change the name of the model, type a name in the Properties window or in the Project Explorer. Open the window of the model by double clicking on the model in the Project Explorer, both windows look like the figure below. The numbers correspond with the steps to implement the response curve.

*User interface for the Fomula-based functions. The numbers correspond with the steps to implement the response curve.*

To determine the response curve, the following steps have to be executed:

- Enter a name for the input variable.
- Double click at the field and select a map by browsing or by selecting a map from previous models. You can also use results from previous models by linking the maps in the Project Explorer.
- Name your output map and fill out the equation. Check if the equation is valid (when the equation is not valid an exclamation mark will be given or an error is given in the messages window)

The user interface will then look like the picture below:

Useful Information

The following PCRaster functions are often used:

'*'

Multiplies the values of two expressions and sends this product to the result, on a cell-by-cell basis.

'**' or '^'

Calculates the n-th power of a first expression, where n is the value on a second expression, and sends it to the result, on a cell-by-cell basis.

'-'

Subtracts the value of the second expression from the value of the first expression and assigns this difference to the result, on a cell-by-cell basis.

'+'

Adds the values of two expressions and assigns this sum to the result, on a cell- by-cell basis.

'/'

Divides the value of a first expression by the value of a second expression and assigns this quotient to the result, on a cell-by-cell basis.

Exp()

calculates the exponent of a value or map

max()

For each cell, determines the maximum value of multiple expressions and assigns it to the corresponding cell for the result.

min()

For each cell, determines the minimum value of multiple expressions and assigns it to the corresponding cell for the result.

If then function:

if(Map1 == 1 then Map2 else 0) is

means if map1 is equal to 1 then take the values from map2 else the value will be 0). HABITAT will change the 'then' and 'else'into a comma, so the function will look like: if(Map1 == 1, Map2,0)

A double == means equal to

> means greater then

< means smaller then

For more information, see the PCRaster Manual.

HABITAT uses a point '.' as a deliminator.

Note that x-values outside the range of the class division will result in a no-data value. Combining a no-data value with one of the input variables will also result in a no-data value. Therefore, it is very important to always check the range of the class division.