This is an old revision of the document!
LESSON 5: Implementing a simple map algebra on Dinamica EGO
In this lesson we would like to demonstrate how to use Dinamica EGO in a very simple way: just converting the values of Belo Horizonte temperature map. We will transform it from Celsius into Fahrenheit.
Which Functors will you use in this lesson?
• Functors: Load Map, Calculate Map and Save Map
Now let us move forward and learn about a very important functor to work with maps: Calculate Map. This functor is used for map algebra: to combine and process maps, tables and constants. Inside Calculate Map it is possible to write expressions that can include arithmetic, logical and conditional elements.
Let's go! Click on the Input/output tab, grab and place on the sketch a Load Map and open the air_temperature.tiff file. Next, click on the Map Algebra tab, grab and place on the sketch one Calculate Map.
Click in the hook tool to create a hook functor with Number Map inside the Calculate Map. The container will resize to accommodate the Number Map. For this, click on the Number Map with the Functor Editor tool and enter “1” (do not write the quotation marks). 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 arrow icon) to establish the connections:
Open the Calculate Map container by grabbing the Edit Functor and 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 “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 Celsius into Fahrenheit:
i1 * 1.8 + 32 or Belo Horizonte Temperature * 1.8 + 32
Click on the Input/output tab, grab and place on the sketch one Save Map and browse to the Dinamica EGO\Guidebook Dinamica_4\Models\Set_1\basics\1_load_save and write the name file (“temperature_fahrenheit.tif”).
The final model will look like this:
Save and run the model by clicking on the run model script button on the top toolbar. The map will look like this: