swn.SurfaceWaterNetwork.coarsen#

SurfaceWaterNetwork.coarsen(level: int)#

Coarsen stream network to a minimum stream order level.

Parameters:
levelint

Minimum stream order level, e.g. 3 to coarsen to 3rd order streams.

Returns:
SurfaceWaterNetwork

With the returned segments attribute, a traced_segnums column containing a segnum list from the original network. If the original network has catchment polygons, the result will aggregate the relevant catchment polygons, listed with a catchment_segnums column.

See also

aggregate

Aggregate segments (and catchments) to a coarser network of segnums.

remove

Remove segments.

Examples

>>> import swn
>>> from shapely import wkt
>>> lines = geopandas.GeoSeries(list(wkt.loads('''\
... MULTILINESTRING(
...     (380 490, 370 420), (300 460, 370 420), (370 420, 420 330),
...     (190 250, 280 270), (225 180, 280 270), (280 270, 420 330),
...     (420 330, 584 250), (520 220, 584 250), (584 250, 710 160),
...     (740 270, 710 160), (735 350, 740 270), (880 320, 740 270),
...     (925 370, 880 320), (974 300, 880 320), (760 460, 735 350),
...     (650 430, 735 350), (710 160, 770 100), (700  90, 770 100),
...     (770 100, 820  40))''').geoms))
>>> lines.index += 100
>>> n = swn.SurfaceWaterNetwork.from_lines(lines)
>>> n2 = n.coarsen(2)
>>> n2.segments[["stream_order", "traced_segnums"]]
    stream_order traced_segnums
102             2          [102]
105             2          [105]
108             3     [106, 108]
109             3          [109]
110             2          [110]
111             2          [111]
118             4     [116, 118]