swn.SurfaceWaterNetwork.remove#

SurfaceWaterNetwork.remove(condition=False, segnums=[])#

Remove segments (and catchments) in-place, preserving attributes.

Parameters:
conditionbool or pandas.Series

Series of bool for each segment index, where True is to remove. Combined with ‘segnums’. Defaut False (keep all).

segnumslist

List of segnums to remove. Combined with ‘condition’. Default [].

Returns:
None

See also

evaluate_upstream_length

Re-evaluate upstream length.

evaluate_upstream_area

Re-evaluate upstream catchment area.

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)
>>> n
<SurfaceWaterNetwork:
  19 segments: [100, 101, ..., 117, 118]
  10 headwater: [100, 101, ..., 115, 117]
  1 outlets: [118]
  no diversions />
>>> n.remove(n.segments.stream_order == 1)
>>> n
<SurfaceWaterNetwork:
  9 segments: [102, 105, ..., 116, 118]
  4 headwater: [102, 105, 110, 111]
  1 outlets: [118]
  no diversions />