topotoolbox.GridObject#

class topotoolbox.GridObject[source]#

Bases: object

A class containing all information of a Digital Elevation Model (DEM).

__init__() None[source]#

Initialize a GridObject instance.

Methods

__init__()

Initialize a GridObject instance.

excesstopography([threshold, method])

Compute the two-dimensional excess topography using the specified method.

fillsinks()

Fill sinks in the digital elevation model (DEM).

identifyflats([raw, output])

Identifies flats and sills in a digital elevation model (DEM).

info()

Prints all variables of a GridObject.

show([cmap])

Display the GridObject instance as an image using Matplotlib.

excesstopography(threshold: float | int | ndarray | GridObject = 0.2, method: str = 'fsm2d') GridObject[source]#

Compute the two-dimensional excess topography using the specified method.

Parameters:
  • threshold (float, int, GridObject, or np.ndarray, optional) – Threshold value or array to determine slope limits, by default 0.2. If a float or int, the same threshold is applied to the entire DEM. If a GridObject or np.ndarray, it must match the shape of the DEM.

  • method (str, optional) –

    Method to compute the excess topography, by default ‘fsm2d’. Options are:

    • ’fsm2d’: Uses the fast sweeping method.

    • ’fmm2d’: Uses the fast marching method.

Returns:

A new GridObject with the computed excess topography.

Return type:

GridObject

Raises:
  • ValueError – If method is not one of [‘fsm2d’, ‘fmm2d’]. If threshold is an np.ndarray and doesn’t match the shape of the DEM.

  • TypeError – If threshold is not a float, int, GridObject, or np.ndarray.

fillsinks() GridObject[source]#

Fill sinks in the digital elevation model (DEM).

Returns:

The filled DEM.

Return type:

GridObject

identifyflats(raw: bool = False, output: list[str] | None = None) tuple[source]#

Identifies flats and sills in a digital elevation model (DEM).

Parameters:
  • raw (bool, optional) – If True, returns the raw output grid as np.ndarray. Defaults to False.

  • output (list of str, optional) – List of strings indicating desired output types. Possible values are ‘sills’, ‘flats’. Order of inputs in list are irrelevant, first entry in output will always be sills. Defaults to [‘sills’, ‘flats’].

Returns:

A tuple containing copies of the DEM with identified flats and/or sills.

Return type:

tuple

Notes

Flats are identified as 1s, sills as 2s, and presills as 5s (since they are also flats) in the output grid. Only relevant when using raw=True.

info() None[source]#

Prints all variables of a GridObject.

show(cmap='terrain') None[source]#

Display the GridObject instance as an image using Matplotlib.

Parameters:

cmap (str, optional) – Matplotlib colormap that will be used in the plot.