Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
Next revision
Previous revision
lesson_17 [2019/08/30 23:56]
argemiro
lesson_17 [2020/02/20 16:12] (current)
pedrog [What will you learn?]
Line 1: Line 1:
 {{ :​logo_logo.png?​400 |}} {{ :​logo_logo.png?​400 |}}
 \\ \\
-=====LESSON 17: Calculating accumulated cost surface and least-cost pathway ​on Dinamica EGO=====  ​+=====LESSON 17: Calculating accumulated cost surface and least-cost pathway=====  ​
 \\ \\
 \\ \\
 ==== What will you learn? ==== ==== What will you learn? ====
-  
-  
- 
   * How to calculate a friction surface, cost surface and least-cost pathway   * How to calculate a friction surface, cost surface and least-cost pathway
   * Functors: \\ - //[[:Calc Cost Map]]//\\ - //[[:Calc Pathway Map]]//   * Functors: \\ - //[[:Calc Cost Map]]//\\ - //[[:Calc Pathway Map]]//
- +This exercise requires the calculation of a friction surface, representing the relative cost of crossing a unit cell depending on the land use. We can express this surface both in terms of distance – no differential cost exists ​among types of land uses; hence the least-cost pathway will be the shortest route, i.e. the Euclidean ​distance – time, financial cost or some type of effort. Thus, this value is calculated in relation to some unit (time, transportation cost, etc).  
-This exercise requires the calculation of a friction surface, representing the relative cost of crossing a unit cell depending on the land use. We can express this surface both in terms of distance – no differential cost exits among types of land uses; hence the least-cost pathway will be the shortest route, i.e. the Euclidian ​distance – time, financial cost or some type of effort. Thus, this value is calculated in relation to some unit (time, transportation cost, etc).  +\\
 In this exercise, we explore the use of the functors //[[:Calc Cost Map]]// and //[[:Calc Pathway Map]]//. To find an optimum solution for the accumulated cost surface, the functor //[[:Calc Cost Map]]// uses a heuristic algorithm that recursively brushes a map until the best cost surface is obtained. As the number of passes increase so does an approximation of an optimum solution. Use “0” for an optimum solution, but in general, only two passes are sufficient to obtain a surface very close to the optimum solution. In this exercise, we explore the use of the functors //[[:Calc Cost Map]]// and //[[:Calc Pathway Map]]//. To find an optimum solution for the accumulated cost surface, the functor //[[:Calc Cost Map]]// uses a heuristic algorithm that recursively brushes a map until the best cost surface is obtained. As the number of passes increase so does an approximation of an optimum solution. Use “0” for an optimum solution, but in general, only two passes are sufficient to obtain a surface very close to the optimum solution.
- +\\
- +
 <WRAP center round help 60%> <WRAP center round help 60%>
 **Question:​** **Question:​**
Line 22: Line 16:
  __Our task is to determine the least-pathway between the town and the existing railroad.__  __Our task is to determine the least-pathway between the town and the existing railroad.__
 </​WRAP>​ </​WRAP>​
- 
- 
- 
- 
 The dataset employed in this exercise comprises: The dataset employed in this exercise comprises:
-  ​ 
    - A land use and cover map of Northern Mato Grosso region, Brazilian Amazon.(Fig.1) (landuse.tif)    - A land use and cover map of Northern Mato Grosso region, Brazilian Amazon.(Fig.1) (landuse.tif)
    - A slope map. (slope.tif)    - A slope map. (slope.tif)
    - A map with the town to be connected. (town1.tif)    - A map with the town to be connected. (town1.tif)
    - A map with the current railroad (railroad.tif)    - A map with the current railroad (railroad.tif)
 +\\
 [{{ :​tutorial:​cost1.1.jpg |Fig.1 Northern Mato Grosso and its location with respect to Brazil.}}] [{{ :​tutorial:​cost1.1.jpg |Fig.1 Northern Mato Grosso and its location with respect to Brazil.}}]
 +\\
 +Open Dinamica EGO and load the aforementioned maps from  ''​Guidebook_Dinamica_5\Database\accumulated_cost_surface_least_cost_pathway''​ on the Map Viewer. Open the slope map using “Pseudocolor” as the current color palette and in the Histogram click on Limits to Actual and Histogram Equalize. As a first step, you need to reclassify the land use map to depict the cost of crossing each one of its land uses. Also you need to reclassify the slope map and then combine it with the land use map. 
  
- +For the land use map we will use the following table:
- +
-Open Dinamica EGO and load the aforementioned maps from  ''​lesson4\originals''​ on the Map Viewer using the color table “mt”. Open the slope map using “Pseudocolor” as the current color palette and in the Histogram click on Limits to Actual and Histogram Equalize. As a first step, you need to reclassify the land use map to depict the cost of crossing each one of its land uses. Also you need to reclassify the slope map and then combine it with the land use map.  +
- +
-For the land use map use the following table:+
  
  
Line 61: Line 48:
 | > 20            | 5  |  | > 20            | 5  | 
  
-Let’s begin the model by loading the maps ''​landuse.tif''​ and ''​slope.tif''​ using the functor //[[:Load Map]]//. Then, let’s incorporate the two previous tables. Add a [[:Lookup Table]] from Lookup Table tab.   +Let’s begin the model by loading the maps ''​landuse.tif''​ and ''​slope.tif''​ using the functor //[[:Load Map]]//. Then, let’s incorporate the two previous tables. Add a //[[:Lookup Table]]// from Lookup Table tab.   
- +\\ 
-You should have something like this:\\+You should have something like this: 
 +\\
 \\ \\
 {{ :​tutorial:​cost2.jpg |}}\\ {{ :​tutorial:​cost2.jpg |}}\\
 \\ \\
 \\ \\
-Now place three //​[[:​Calculate Map]]// and four //[[:Number Map]]// functors, one within each //​[[:​Calculate Map]]// and two //[[:Number Map]]// functors within the third, and one //[[:Number Table]]// within one of the two first //​[[:​Calculate Map]]// functors and //[[:Save Map]]//. Open //[[:Number Map]]//, assign a unique number (1 and 2) to each one and assign "​1"​ to //[[:Number Table]]//. Finally connect Map ''​landuse.tif''​ and Map ''​slope.tif''​ to //[[:Number Map]]// 1 of the two first //​[[:​Calculate Map]]//. Then, connect the two first to the third //​[[:​Calculate Map]]// respectively and it to //[[:Save Map]]//. Open //[[:Save Map]]// and enter ''​friction.tif''​. This is what you get. +Now place three //​[[:​Calculate Map]]// and four //[[:Number Map]]// functors, one within each //​[[:​Calculate Map]]// and two //[[:Number Map]]// functors within the third, and one //[[:Number Table]]// within one of the two first //​[[:​Calculate Map]]// functors and //[[:Save Map]]//. Open //[[:Number Map]]//, assign a unique number (1 and 2) to each one and assign "​1"​ to //[[:Number Table]]//. Finally connect Map ''​landuse.tif''​ and Map ''​slope.tif''​ to //[[:Number Map]]// 1 of the two first //​[[:​Calculate Map]]//. Then, connect the two first to the third //​[[:​Calculate Map]]// respectively and it to //[[:Save Map]]//. Open //[[:Save Map]]// and enter ''​friction.tif''​. This is what you should ​get: 
 +\\
 {{ :​tutorial:​cost3.jpg |}} {{ :​tutorial:​cost3.jpg |}}
 +\\
 Now, you need to enter the land use table in the functor //[[:Lookup Table]]//. Open it with Edit Functor and start adding **keys** and **values** (fill in the fields and press the plus button). Open the //​[[:​Calculate Map]]// that contains the //[[:Number Table]]// and write the following formula: **t1[i1]**\\ Now, you need to enter the land use table in the functor //[[:Lookup Table]]//. Open it with Edit Functor and start adding **keys** and **values** (fill in the fields and press the plus button). Open the //​[[:​Calculate Map]]// that contains the //[[:Number Table]]// and write the following formula: **t1[i1]**\\
 \\ \\
 \\ \\
-{{:​tutorial:​cost4.jpg|}}{{ :​tutorial:​cost5.jpg|}} +{{ :​tutorial:​cost4.jpg |}} 
- +\\ 
-This formula will get the value from the map and use it as a key to access the table, ​therefore ​reclassifying the map according to the cost values.\\+{{ :​tutorial:​cost5.jpg |}} 
 +\\ 
 +\\ 
 +This formula will get the value from the map and use it as a key to access the table, reclassifying the map according to the cost values. 
 +\\
 \\  \\ 
-Enter the following equation into the second //​[[:​Calculate Map]]//:\\+Enter the following equation into the second //​[[:​Calculate Map]]//: 
 +\\
 \\  \\ 
-**if i1 < 1 then 1 else if i1 < 5 then 1.3 else if i1 < 10 then 1.5 else if i1 < 15 then 1.9 else if i1 < 20 then 2.5 else 5**\\ +    ​if i1 < 1 then 1 else if i1 < 5 then 1.3 else if i1 < 10 then 1.5 else if i1 < 15 then 1.9 else if i1 < 20 then 2.5 else 5 
-This corresponds to the slope friction table.\\+\\ 
 +\\ 
 +This corresponds to the slope friction table. 
 +\\
 \\  \\ 
-In the third //​[[:​Calculate Map]]// enter:\\ +In the third //​[[:​Calculate Map]]// enter:
- +
-**i1*i2**\\+
 \\ \\
-Save the model as ''​my_friction'',​ and run it.\\+\\ 
 +    i1*i2 
 +\\ 
 +\\ 
 +Save the model as ''​my_friction'',​ and run it.
 \\ \\
 Open on the Map Viewer ''​friction.tif'',​ using “Pseudocolor” as Current Color Palette and in the Histogram click on Limits to Actual and Histogram Equalize. ​ Open on the Map Viewer ''​friction.tif'',​ using “Pseudocolor” as Current Color Palette and in the Histogram click on Limits to Actual and Histogram Equalize. ​
 +\\
 What do you see? Observe the red color representing the areas with high costs to cross. ​ What do you see? Observe the red color representing the areas with high costs to cross. ​
 +\\ 
 +\\
 {{ :​tutorial:​cost6.1.jpg |}} {{ :​tutorial:​cost6.1.jpg |}}
- +\\ 
-<​note>​You may feel free to use other software to view the maps.</​note>​ +\\ 
- +Let’s move on to the second part of this exercise. ​ 
-Let’s move on to the second part of this exercise. Load ''​town1.tif''​ from ''​\originals''​ using //[[:Load Map]]// and ''​railroad.tif''​ using //[[:Load Categorical Map]]//. Remember that this functor categorizes a map.\\+\\ 
 +Load ''​town1.tif''​ from ''​\originals''​ using //[[:Load Map]]// and ''​railroad.tif''​ using //[[:Load Categorical Map]]//. Remember that this functor categorizes a map. 
 +\\
 Drag //[[:Calc Cost Map]]// and //[[:Calc Pathway Map]]// from the Map Algebra tab and //[[:Save Map]]//​. ​ Drag //[[:Calc Cost Map]]// and //[[:Calc Pathway Map]]// from the Map Algebra tab and //[[:Save Map]]//​. ​
 +\\
 <WRAP center round info 60%> <WRAP center round info 60%>
 Here are some notes on this algorithm:​\\ Here are some notes on this algorithm:​\\
 \\ \\
-The algorithm that calculates the cost map is a general type of "​Pushbroom"​. However its spatial performance approximates the so called "​Pushgrow"​ algorithm, especially when using two or more passes.\\+The algorithm that calculates the cost map is a general type of "​Pushbroom"​. Howeverits spatial performance approximates the so called "​Pushgrow"​ algorithm, especially when using two or more passes.\\
 \\  \\ 
 By default, the cells dimensions (width and height) are not considered in the calculation of cost. To take this into consideration,​ turn on in Advanced options **Friction is relative**.\\ By default, the cells dimensions (width and height) are not considered in the calculation of cost. To take this into consideration,​ turn on in Advanced options **Friction is relative**.\\
Line 115: Line 116:
 \\  \\ 
 Unreachable places on the friction map are excluded on the cost map and thus represented as null value cells. Cost are not accumulated across null value cells, thus regions surrounded by null value cells will not have their cell costs calculated, unless there is a source feature inside this region. Unreachable places on the friction map are excluded on the cost map and thus represented as null value cells. Cost are not accumulated across null value cells, thus regions surrounded by null value cells will not have their cell costs calculated, unless there is a source feature inside this region.
-</​WRAP>​\\ +</​WRAP>​ 
 +\\
 The **Source** port of [[:Calc Cost Map]] functor will receive the Map ''​railroad.tif''​ and the **Friction** port will receive the map output by the third //​[[:​Calculate Map]]//. Turn on **Diagonals Cost More**. This will penalize the movement across diagonal cells. Set **Maximum Number of Passes** to “2”. Leave all other options untouched. The **Source** port of [[:Calc Cost Map]] functor will receive the Map ''​railroad.tif''​ and the **Friction** port will receive the map output by the third //​[[:​Calculate Map]]//. Turn on **Diagonals Cost More**. This will penalize the movement across diagonal cells. Set **Maximum Number of Passes** to “2”. Leave all other options untouched.
- 
-Open //[[:Calc Pathway Map]]// now with the Edit Functor Ports. ​ 
- 
-Link Map ''​town1.tif''​ to the **Source** port <note tip>​**TIP**:​ **Source**, in this case, also represents the destiny since the cost map was built from the existing railroad. Thus, this algorithm will search for the least-cost pathway from the source to the existing feature, i.e. the railroad.</​note> ​ 
- 
-Link the map output from //[[:Calc Cost Map]]// to the port **Cost** and Map ''​railroad.tif''​ to **Network** (because it represents a linear feature network) and the output **Network** port to //[[:Save Map]]//. {{ :​tutorial:​cost8.2.jpg |}} 
- 
-Activate the option **Use Lottery** (this is an artifact that permits the model to solve the path when two or more local minima are found).\\ 
 \\ \\
- +Open //[[:Calc Pathway Map]]// ​now with the Edit Functor PortsLink Map ''​town1.tif'' ​to the **Source** port.
-{{ :​tutorial:​cost9.jpg?​300|}}//[[:Calc Pathway Map]]// ​ignores cells with values equal or lesser than 0 or null cellsIn turn //[[:Calc Cost Map]]// needs a network map with null cells representing non-featuresGo to //[[:Load Categorical Map]]// and open it with the Edit Functor. Press the flag **Null Value** and make sure **Use specific value** is set to “0”.\\+
 \\ \\
 +<note tip>​**TIP**:​ **Source**, in this case, also represents the destiny since the cost map was built from the existing railroad. Thus, this algorithm will search for the least-cost pathway from the source to the existing feature, i.e. the railroad.
 +</​note> ​
 +\\
 +Link the map output from //[[:Calc Cost Map]]// to the port **Cost** and Map ''​railroad.tif''​ to **Network** (because it represents a linear feature network) and the output **Network** port to //[[:Save Map]]//​. ​
 +\\
 +\\
 +{{ :​tutorial:​cost8.2.jpg |}}
 +\\
 +\\
 +Activate the option **Use Lottery** (this is an artifact that allows the model to solve the path when two or more local minima are found).
 +\\
 +\\
 +{{ :​tutorial:​cost9.jpg?​300 |}}
 +\\
 +\\
 +//[[:Calc Pathway Map]]// ignores cells with values equal, less than 0 or null cells. In turn //[[:Calc Cost Map]]// needs a network map with null cells representing non-features. Go to //[[:Load Categorical Map]]// and open it with the Edit Functor. Press the flag **Null Value** and make sure **Use specific value** is set to “0”.
 +\\
 +\\
 +Click on //[[:Save Map]]// with the Edit Functor, change the folder to an upper level, change the file format to “geotiff” and set **Suffix to Digits** to “0”, finally enter ''​railway.tif''​. The final model will look as follows: ​
 +\\
 +\\
 +{{ :​tutorial:​cost10.jpg |}}
 \\ \\
 \\ \\
-Click on //[[:Save Map]]// with the Edit Functor, change the folder to an upper level, change the file format to “geotiff” and set **Suffix to Digits** to “0”, finally enter ''​railway.tif''​. The final model will look as follows: {{ :​tutorial:​cost10.jpg |}} 
- 
 Save the model to a new file ''​my_pathway.egoml'',​ and run it. This is going to take only a little while. Dinamica EGO has superior performance in relation to most commercial GIS packages; you may want to try this model on other software just for performance comparison. Open on the Map viewer ''​railway.tif'',​ using "​PseudoColor"​ as **Current Color Palette**. What do you see?​\\ ​ Save the model to a new file ''​my_pathway.egoml'',​ and run it. This is going to take only a little while. Dinamica EGO has superior performance in relation to most commercial GIS packages; you may want to try this model on other software just for performance comparison. Open on the Map viewer ''​railway.tif'',​ using "​PseudoColor"​ as **Current Color Palette**. What do you see?​\\ ​
 \\ \\
Line 139: Line 151:
 \\ \\
 \\ \\
-You may try to maximize the solution for the //[[:Calc Cost Map]]// algorithm by setting the **Maximum Number of Passes** to “0”. Compare the time spent by this run and its resulting path with that of previous modelDid it make a big difference?​\\+You may try to maximize the solution for the //[[:Calc Cost Map]]// algorithm by setting the **Maximum Number of Passes** to “0”. Compare the time spent by this run and its resulting path with that of previous modelDid it make a big difference? 
 +\\
 \\ \\
 This type of model can also be modified to develop simultaneously multiple paths. Open the model ''​join_towns.egoml''​ in lesson 4 folder.{{ :​tutorial:​cost12.jpg |}} This type of model can also be modified to develop simultaneously multiple paths. Open the model ''​join_towns.egoml''​ in lesson 4 folder.{{ :​tutorial:​cost12.jpg |}}
-  +\\ 
-This model shows how you can use //​[[:​Calculate Map]]// to merge information from several maps into a single one. The product will be a map depicting the center cells for four towns. TIP: use always a sole cell to represent a location to be reached by //[[:Calc Pathway Map]]//​.\\ +\\ 
- +This model shows how you can use //​[[:​Calculate Map]]// to merge information from several maps into a single one. The product will be a map depicting the center cells for four towns. TIP: use always a sole cell to represent a location to be reached by //[[:Calc Pathway Map]]//. 
-Now replace, into model my_pathway.egoml,​ the input in Map ''​town1.tif''​ with the file ''​multiple_towns.tif''​ and change the file in Map ''​railway.tif''​ to ''​xrailways.tif''​.\\ +\\ 
- +\\ 
-Did you get something like this?\\ +Now replace, into model my_pathway.egoml,​ the input in Map ''​town1.tif''​ with the file ''​multiple_towns.tif''​ and change the file in Map ''​railway.tif''​ to ''​xrailways.tif''​. 
 +\\ 
 +\\ 
 +Did you get something like this? 
 +\\ 
 +\\
 {{ :​tutorial:​cost13.2.jpg |}}\\ {{ :​tutorial:​cost13.2.jpg |}}\\
 \\ \\
-If you go to ''​Examples\run_lucc_northern_mato_grosso\run_roads_with_comments''​ and open the model ''​mato_grosso_road.egoml'',​ you will see how this set of algorithms can be adapted and combined to build a Road Constructor Module, a submodel that simulates the expansion of the road network in an Amazonian frontier region. This model is an example of the ability of Dinamica EGO platform for the ingenious design of spatial models. 
 \\ \\
 +===Congratulations,​ you have successfully completed this lesson!===
 \\ \\
-Congratulations,​ you have successfully completed this lesson! Now let’s move to the **next lesson:​** ​[[lesson_18|LESSON 18Building a land-use and land-cover change simulation model]]+☞ [[lesson_18|Next Lesson]] 
 +\\ 
 +☞[[:guidebook_start| Back to Guidebook Start]]