Differences

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

Link to this comparison view

Both sides previous revision Previous revision
calc_flow_direction_map [2015/10/13 20:04]
admin
calc_flow_direction_map [2026/08/28 03:09] (current)
hermann Sync from local documentation review
Line 3: Line 3:
 ===== Description ===== ===== Description =====
  
-This functor calculates ​a flow direction map using an elevation map.+Calculates ​a flow direction map from an elevation map: for each cell, the direction toward the neighboring cell with the steepest downhill slope, or, when requested, every downhill direction combined into a single value.
  
 ===== Inputs ===== ===== Inputs =====
  
 ^ Name  ^ Type  ^ Description ​ ^ ^ Name  ^ Type  ^ Description ​ ^
-| Elevation ​  ​| [[Map Type]] ​ | Elevation map. The elevation ​unit is not relevant.  |+| Elevation ​ | [[Map Type]] ​ | Elevation map for which the flow is determined. The unit of elevation does not matter. A null cell remains null in the output.  |
  
 ===== Optional Inputs ===== ===== Optional Inputs =====
  
 ^ Name  ^ Type  ^ Description ​ ^ Default Value  ^ ^ Name  ^ Type  ^ Description ​ ^ Default Value  ^
-| Diagonals Are Longer ​ | [[Boolean Value Type]] ​ | If true, the flow between ​diagonal ​cells is attenuated ​by the square root of two.  | True  | +| Diagonals Are Longer ​ | [[Boolean Value Type]] ​ | If true, diagonal ​neighbor'​s center ​is treated as farther from the evaluated cell's center than an orthogonal neighbor'​s,​ attenuating its slope by the square root of two. This is an advanced port.  | Yes  | 
-| Return All Directions ​ | [[Boolean Value Type]] ​ | If true, the functor returns ​the flow directions leaving a cell packed as a bitwise-OR combination of all possible directions.  | False  | +| Return All Directions ​ | [[Boolean Value Type]] ​ | If true, the output cell holds the bitwise combination of every direction with a downhill slope. If false, it holds only the direction of the steepest downhill slope. This is an advanced port.  | No  | 
-| Use Lottery ​ | [[Boolean Value Type]] ​ | If true, the functor chooses randomly between possible directionsThis flag only makes sense if the flag "Return All Directions" ​is false. ​ | False  | +| Use Lottery ​ | [[Boolean Value Type]] ​ | If true, and two or more neighbors are tied for the steepest downhill slope, one is chosen at randomIf false, ​the first one evaluated is chosen. Only meaningful when Return All Directions is false. This is an advanced port.  | No  | 
-| Flow Also In Flat Areas  | [[Boolean Value Type]] ​ | If true, this functor also calculates flow direction for flat areas (zero slope cells). It is worth noting that, if a cell has eight neighbors ​with the same elevation, but at least one has flow directionthe flow will point toward ​that cell. | True  | +| Flow Also In Flat Areas  | [[Boolean Value Type]] ​ | If true, a cell whose neighbors ​are all at the same elevation ​(so it would otherwise get no flow direction) is assigned ​the direction of a same-elevation neighbor ​that does have a flow directionThis is an advanced port.  ​Yes  | 
-| Flow Direction Is Sparse ​ | [[Boolean Value Type]] ​ | If true, the map is loaded ​as a sparse ​image. Sparse images have the advantage of storing ​only the cells containing ​non-null ​valuesbut they have worse access ​time.  | False  |+| Flow Direction Is Sparse ​ | [[Boolean Value Type]] ​ | If true, the flow direction ​map is stored ​as a sparse ​raster, which stores ​only non-null ​cellstrading faster ​access ​for lower memory use. This is an advanced port.  | No  |
  
 ===== Outputs ===== ===== Outputs =====
  
 ^ Name  ^ Type  ^ Description ​ ^ ^ Name  ^ Type  ^ Description ​ ^
-| Flow Directions ​ | [[Map Type]] ​ | Flow direction map. Every non-null cell from this map contains a value indicating ​the direction ​toward the steepest ​slope (or the bit-wised combination ​of all possible directions, whether "Return All Directions" ​is true).  |+| Flow Directions ​ | [[Map Type]] ​ | Map where each non-null cell holds the direction ​of its steepest ​downhill neighbor, ​or the combined bitmask ​of every downhill direction when Return All Directions is true.  |
  
 ===== Group ===== ===== Group =====
Line 30: Line 30:
 ===== Notes ===== ===== Notes =====
  
-Null value elevation cells are ignored.+Directions ​are encoded using the following mask, read clockwise starting from the neighbor directly to the right of the evaluated cell (X): 32, 64, and 128 for the neighbors above; 16 and 1 for the neighbors to the left and right; 8, 4, and 2 for the neighbors below. Several directions can be packed into a single value by summing them, which is what Return All Directions does.
  
-The values in the output ​map indicate the directions as follows: +See [[Calc Cumulative Flow Map]], which consumes this functor'​s ​output.
- +
-|  32  |  64  |  128  | +
-|  16  |  x   ​| ​ 1    | +
-|  8   ​| ​ 4   ​| ​ 2    | +
- +
-where X is the current cell and the other cells indicate their corresponding position mask. +
- +
-The resulting directions can be summed to pack several directions in a single value.+
  
 ===== Internal Name ===== ===== Internal Name =====