SumDownStream¶
Sums the values of a map downstream, along the drainage directions: each cell gets the sum of the values of all the cells upstream of it, itself included. With a map of ones it gives the contributing area; with other maps, how much of something the water collects on its way: the unstable areas, the sources of sediment, the volume of water of each cell.
The cells with values outside the thresholds are not summed, and stop the paths that reach them. The paths end at the outlets marked with the value 10 in the drainage directions, for example with MarkOutlets.
Parameters¶
Sums the values of a map downstream, along the drainage directions: each cell gets the sum of the values of the cells upstream of it, itself included. The values outside the thresholds are not summed, and stop the paths.
Toolbox folder: Statistics
Status: Certified
Keywords: Statistics, Downstream, Drainage directions
Authors: Daniele Andreis, Antonello Andrea, Erica Ghesla, Cozzini Andrea, Franceschi Silvia, Pisoni Silvano, Rigon Riccardo
Class: org.hortonmachine.modules.SumDownStream
Inputs
Parameter |
Type |
Unit |
Default |
Description |
|---|---|---|---|---|
|
raster file |
The map of the drainage directions. |
||
|
raster file |
The map of the values to sum. |
||
|
Double |
The value from which the values are not summed. |
||
|
Double |
The value up to which the values are not summed. |
Outputs
Parameter |
Type |
Unit |
Description |
|---|---|---|---|
|
output file |
The map of the sums of the values upstream. |
Example¶
The example runs on the sample elevation model of the manual, dtm_flanginec.tif in docs/manual/modules/maps/data, each module on the outputs of the previous ones:
import org.hortonmachine.modules.Mapcalc
import org.hortonmachine.modules.SumDownStream
// the folder with the elevation model: change it to yours
var folder = "/data/flanginec/"
// 1 for the cells unstable in the map of Shalstab, 0 for the others
var mapcalc = new Mapcalc()
mapcalc.inRaster1 = folder + "shalstab.tif"
mapcalc.pFunction = """
images {
shalstab = read;
unstable = write;
}
unstable = con(shalstab == 1 || shalstab == 4, 1, 0);
"""
mapcalc.outRaster = folder + "unstable.tif"
mapcalc.process()
// the number of unstable cells upstream, in the basin of ExtractBasin
var sum = new SumDownStream()
sum.inFlow = folder + "drain_marked.tif"
sum.inToSum = folder + "unstable.tif"
sum.outSummed = folder + "unstable_upstream.tif"
sum.process()
The number of cells upstream of each cell of the basin of ExtractBasin that are unstable in the map of Shalstab, made of ones and zeros with the Mapcalc module.¶