priority_flow.border_direction_fix
Border direction fixing functions for PriorityFlow.
This module contains functions for correcting the flow directions of border cells based on slope analysis to ensure proper drainage patterns.
Functions
|
Fix the directions of border cells. |
Module Contents
- priority_flow.border_direction_fix.fix_border_dir(direction: numpy.ndarray, dem: numpy.ndarray, d4: Tuple[int, int, int, int] = (1, 2, 3, 4)) numpy.ndarray[source]
Fix the directions of border cells.
Originally all border cells are initialized to point out of the domain. This function checks the slopes and areas to determine if they need to swap direction to point into the domain instead.
NOTE: This function is not yet tested.
- Parameters:
direction (np.ndarray) – Flow direction matrix [nx, ny] - will be modified in place
dem (np.ndarray) – Digital Elevation Model matrix [nx, ny]
d4 (tuple, optional) – Direction numbering system for down, left, top, right. Defaults to (1, 2, 3, 4).
- Returns:
The modified direction array
- Return type:
np.ndarray
Notes
This is a Python port of the R function FixBorderDir from PriorityFlow. The function analyzes slopes at domain boundaries to determine whether border cells should drain inward or outward.
WARNING: This function modifies the input direction array in place for backwards compatibility with the R version.
Direction mapping: - d4[0] = 1: Down - d4[1] = 2: Left - d4[2] = 3: Up - d4[3] = 4: Right