network.NetworkReach

network.NetworkReach()

Abstract base class for a reach in a network.

A reach represents a directed connection between two :class:NetworkNode instances (e.g. a river reach between two junctions). It may also carry a list of :class:ReachBreakPoint objects for intermediate chainage locations.

Subclass this to integrate your own network topology. Four properties must be implemented:

  • :attr:id - a unique string identifier for the reach.
  • :attr:start - the upstream/start :class:NetworkNode.
  • :attr:end - the downstream/end :class:NetworkNode.
  • :attr:breakpoints - list of :class:ReachBreakPoint instances ordered by increasing distance from the start node (empty list if none).

:attr:length is optional and defaults to None. Reach length matters in some domains (rivers, sewer networks) and not in others (link-node water distribution models), so override it only where a length exists.

:attr:start_distance and :attr:end_distance say where the reach’s own ends sit in the frame its break points are placed in. They default to 0.0 and the length, which is right wherever break points are measured from the start node; override them where the frame is offset.

The concrete helper :class:BasicReach is provided for the common case where all data is already available in memory.

Examples

Minimal subclass, without a length:

>>> class MyReach(NetworkReach):
...     def __init__(self, rid, start_node, end_node):
...         self._id = rid
...         self._start = start_node
...         self._end = end_node
...     @property
...     def id(self): return self._id
...     @property
...     def start(self): return self._start
...     @property
...     def end(self): return self._end
...     @property
...     def breakpoints(self): return []

Add a :attr:length property on top of that when the domain has one:

>>> class MyMeasuredReach(MyReach):
...     def __init__(self, rid, start_node, end_node, length):
...         super().__init__(rid, start_node, end_node)
...         self._length = length
...     @property
...     def length(self): return self._length

See Also

BasicReach : Ready-to-use concrete implementation. NetworkNode : Represents the start/end of this reach. ReachBreakPoint : Intermediate data points along this reach. Network : Assembles a list of NetworkReach objects into a graph.

Attributes

Name Description
breakpoints Ordered list of intermediate :class:ReachBreakPoint objects (may be empty).
end End (downstream) node of this reach.
end_distance Position of the end node, or None where the length is undefined.
id Unique string identifier for this reach.
length Total length of this reach in network units, or None if undefined.
n_breakpoints Number of break points in the reach.
start Start (upstream) node of this reach.
start_distance Position of the start node, in the frame :attr:breakpoints are placed in.