# RichDEM Python Reference¶

richdem.BreachDepressions(dem, in_place=False, topology='D8')

Breaches all depressions in a DEM.

Parameters: dem (rdarray) – An elevation model in_place (bool) – If True, the DEM is modified in place and there is no return; otherwise, a new, altered DEM is returned. topology (string) – A topology indicator DEM without depressions.
richdem.FillDepressions(dem, epsilon=False, in_place=False, topology='D8')

Fills all depressions in a DEM.

Parameters: dem (rdarray) – An elevation model epsilon (float) – If True, an epsilon gradient is imposed to all flat regions. This ensures that there is always a local gradient. in_place (bool) – If True, the DEM is modified in place and there is no return; otherwise, a new, altered DEM is returned. topology (string) – A topology indicator DEM without depressions.
richdem.FlowAccumFromProps(props, weights=None, in_place=False)

Calculates flow accumulation from flow proportions.

Parameters: props (rdarray) – An elevation model weights (rdarray) – Flow accumulation weights to use. This is the amount of flow generated by each cell. If this is not provided, each cell will generate 1 unit of flow. in_place (bool) – If True, then weights is modified in place. An accumulation matrix is always returned, but it will just be a view of the modified data if in_place is True. A flow accumulation array. If weights was provided and in_place was True, then this matrix is a view of the modified data.
richdem.FlowAccumulation(dem, method=None, exponent=None, weights=None, in_place=False)

Calculates flow accumulation. A variety of methods are available.

Parameters: dem (rdarray) – An elevation model method (str) – Flow accumulation method to use. (See below.) exponent (float) – Some methods require an exponent; refer to the relevant publications for details. weights (rdarray) – Flow accumulation weights to use. This is the amount of flow generated by each cell. If this is not provided, each cell will generate 1 unit of flow. in_place (bool) – If True, then weights is modified in place. An accumulation matrix is always returned, but it will just be a view of the modified data if in_place is True.
Method Note Reference
Tarboton Alias for Dinf. Taroboton (1997) doi: 10.1029/96WR03137
Dinf Alias for Tarboton. Taroboton (1997) doi: 10.1029/96WR03137
Quinn Holmgren with exponent=1. Quinn et al. (1991) doi: 10.1002/hyp.3360050106
Holmgren(E) Generalization of Quinn. Holmgren (1994) doi: 10.1002/hyp.3360080405
Freeman(E) TODO Freeman (1991) doi: 10.1016/0098-3004(91)90048-I
FairfieldLeymarieD8 Alias for Rho8. Fairfield and Leymarie (1991) doi: 10.1029/90WR02658
FairfieldLeymarieD4 Alias for Rho4. Fairfield and Leymarie (1991) doi: 10.1029/90WR02658
Rho8 Alias for FairfieldLeymarieD8. Fairfield and Leymarie (1991) doi: 10.1029/90WR02658
Rho4 Alias for FairfieldLeymarieD4. Fairfield and Leymarie (1991) doi: 10.1029/90WR02658
OCallaghanD8 Alias for D8. O’Callaghan and Mark (1984) doi: 10.1016/S0734-189X(84)80011-0
OCallaghanD4 Alias for D8. O’Callaghan and Mark (1984) doi: 10.1016/S0734-189X(84)80011-0
D8 Alias for OCallaghanD8. O’Callaghan and Mark (1984) doi: 10.1016/S0734-189X(84)80011-0
D4 Alias for OCallaghanD4. O’Callaghan and Mark (1984) doi: 10.1016/S0734-189X(84)80011-0

Methods marked (E) require the exponent argument.

Returns: A flow accumulation according to the desired method. If weights was provided and in_place was True, then this matrix is a view of the modified data.
richdem.FlowProportions(dem, method=None, exponent=None)

Calculates flow proportions. A variety of methods are available.

Parameters: dem (rdarray) – An elevation model method (str) – Flow accumulation method to use. (See below.) exponent (float) – Some methods require an exponent; refer to the relevant publications for details.
Method Note Reference
Tarboton Alias for Dinf. Taroboton (1997) doi: 10.1029/96WR03137
Dinf Alias for Tarboton. Taroboton (1997) doi: 10.1029/96WR03137
Quinn Holmgren with exponent=1. Quinn et al. (1991) doi: 10.1002/hyp.3360050106
Holmgren(E) Generalization of Quinn. Holmgren (1994) doi: 10.1002/hyp.3360080405
Freeman(E) TODO Freeman (1991) doi: 10.1016/0098-3004(91)90048-I
FairfieldLeymarieD8 Alias for Rho8. Fairfield and Leymarie (1991) doi: 10.1029/90WR02658
FairfieldLeymarieD4 Alias for Rho4. Fairfield and Leymarie (1991) doi: 10.1029/90WR02658
Rho8 Alias for FairfieldLeymarieD8. Fairfield and Leymarie (1991) doi: 10.1029/90WR02658
Rho4 Alias for FairfieldLeymarieD4. Fairfield and Leymarie (1991) doi: 10.1029/90WR02658
OCallaghanD8 Alias for D8. O’Callaghan and Mark (1984) doi: 10.1016/S0734-189X(84)80011-0
OCallaghanD4 Alias for D8. O’Callaghan and Mark (1984) doi: 10.1016/S0734-189X(84)80011-0
D8 Alias for OCallaghanD8. O’Callaghan and Mark (1984) doi: 10.1016/S0734-189X(84)80011-0
D4 Alias for OCallaghanD4. O’Callaghan and Mark (1984) doi: 10.1016/S0734-189X(84)80011-0

Methods marked (E) require the exponent argument.

Returns: A flow proportion according to the desired method.
richdem.LoadGDAL(filename, no_data=None)

Opens any file GDAL can read, selects the first raster band, and loads it and its metadata into a RichDEM array of the appropriate data type.

If you need to do something more complicated, look at the source of this function.

Parameters: filename (str) – Name of the raster file to open no_data (float) – Optionally, set the no_data value to this. A RichDEM array
richdem.ResolveFlats(dem, in_place=False)

Attempts to resolve flats by imposing a local gradient

Parameters: dem (rdarray) – An elevation model in_place (bool) – If True, the DEM is modified in place and there is no return; otherwise, a new, altered DEM is returned. DEM modified such that all flats drain.
richdem.SaveGDAL(filename, rda)

Save a GDAL file.

Saves a RichDEM array to a data file in GeoTIFF format.

If you need to do something more complicated, look at the source of this function.

Parameters: filename (str) – Name of the raster file to be created rda (rdarray) – Data to save. No Return
richdem.TerrainAttribute(dem, attrib, zscale=1.0)

Calculates terrain attributes. A variety of methods are available.

Parameters: dem (rdarray) – An elevation model attrib (str) – Terrain attribute to calculate. (See below.) zscale (float) – How much to scale the z-axis by prior to calculation
Method Reference
slope_riserun Horn (1981) doi: 10.1109/PROC.1981.11918
slope_percentage Horn (1981) doi: 10.1109/PROC.1981.11918
slope_degrees Horn (1981) doi: 10.1109/PROC.1981.11918
class richdem.rd3array
class richdem.rdarray