### LESSON 5: Implementing simple map algebra on Dinamica EGO

In this lesson we demonstrate how to use Dinamica EGO to convert the values of Belo Horizonte temperature map from Celsius into the Fahrenheit scale.

**Which Functors will you use in this lesson?** Load Map, Calculate Map and Save Map

The Calculate Map functor is for map algebra: to combine and process maps, tables and constants. Inside Calculate Map it is possible to write expressions that including arithmetic, logical and conditional elements.

**Let's go!**

Click on the Input/Output tab, drag a Load Map to the sketch and open the `air_temperature.tif`

file used in the previous lesson. Next, click on the Map Algebra tab, grab and place on the sketch one Calculate Map and one Save Map functor. In the Save Map functor browse to `Guidebook_Dinamica_5\Models\simple_map_algebra`

and write the file name `temperature_fahrenheit.tif`

.

Select the Calculate Map and click on the hook tool on action bar to create a Number Map inside the Calculate Map if there isn't one already. The container will resize to accommodate the Number Map. Double click on the Number Map and enter “1” (do not write the quotation marks) as the Map Number. This is a number identifier for a map and will be represented within the equation box as `i1`

(input 1).

Now you can connect the functor Load Map to the Number Map. Use the connect tool (the lightning icon) to establish the connections. Note that the connection must be established between the Load Map functor and the Number Map inside of Calculate Map and not to Calculate Map itself.

Open Calculate Map by double clicking on it. Note that map #1 is represented by `i1`

. The Calculate Map enables the formulation of various algebraic and logic equations containing maps, tables and constants.

Besides writing the equation, there are two parameters that must be set: The Cell Type and the Null Value. You will always find these parameters in functors that produce maps as output. The default is set to “Signed 32 Bit Integer”, but you can use “IEEE 754 32 Bit Real” to represent fractional numbers.

Now, let’s write a simple equation to convert the Belo Horizonte temperature in the Celsius scale to Fahrenheit:

i1 * 1.8 + 32

where `i1`

represents the `Belo Horizonte Temperature`

map.

Despite the fact that the expression is presented using the alias of the functor from where the corresponding map is coming, you specify the map in the expression just typing the identifier i1. Momentarily, that identifier will be automatically replaced by the corresponding map alias. Another easy option to enter the map identifier is to click on the corresponding map name on the list above the image expression.

The final model will look like this:

Save and run the model by clicking on the run model script button on the main toolbar. After adjusting limits and choosing a suitable transformation, as in the previous lesson, the map will look like this:

Congratulations, you have successfully completed this lesson!

☞ Next Lesson

☞ Back to Guidebook Start