result_network.ResultReaches

result_network.ResultReaches(self, res1d)

Class for wrapping ResultData reaches.

By itself it is also a dict, which contains mapping between reach name and IRes1DReach object or a list of IRes1DReach objects.

Parameters

Name Type Description Default
res1d Res1D Res1D object the reaches belong to. required

Attributes

Name Description
derived_quantities A list of available derived quantities.
group The TimeSeriesIdGroup associated with these locations.
locations A list of location objects (e.g. ).
names A list of location names (e.g. MUIDs).
quantities A list of available quantities.
res1d The Res1D instance that these locations belong to.

Methods

Name Description
read Read the time series data for all quantities at these locations into a DataFrame.
to_geopandas Convert reaches to a geopandas.GeoDataFrame object.

read

result_network.ResultReaches.read(column_mode=None, include_derived=False)

Read the time series data for all quantities at these locations into a DataFrame.

Parameters

Name Type Description Default
column_mode str | ColumnMode(optional) Specifies the type of column index of returned DataFrame. ‘all’ - column MultiIndex with levels matching TimeSeriesId objects. ‘compact’ - same as ‘all’, but removes levels with default values. ‘timeseries’ - column index of TimeSeriesId objects None
include_derived bool Include derived quantities. False

to_geopandas

result_network.ResultReaches.to_geopandas(
    agg=None,
    agg_kwargs={},
    segmented=True,
    include_derived=False,
)

Convert reaches to a geopandas.GeoDataFrame object.

By default, quantities are not included. To include quantities, use the agg and agg_kwargs parameters.

Parameters

Name Type Description Default
agg str or callable Defines how to aggregate the quantities in time and space. Accepts any str or callable that is accepted by pandas.DataFrame.agg. None

Examples

- 'mean'  : mean value of all quantities
- 'max'   : maximum value of all quantities
-  np.max : maximum value of all quantities

agg_kwargs : dict, default {} Aggregation function for specific column levels (e.g. {time=‘min’, chainage=‘first’}). segmented : bool, (default=True) True - one LineString per IRes1DReach object. False - one LineString per reach name. include_derived : bool, default False Include derived quantities.

Returns

Name Type Description
gdf geopandas.GeoDataFrame A GeoDataFrame object with reaches as LineString geometries.

Examples

Convert reaches to a GeoDataFrame (without quantities)

>>> gdf = res1d.reaches.to_geopandas()

Convert reaches to a GeoDataFrame with aggregated quantities

>>> gdf = res1d.reaches.to_geopandas(agg='mean')