Link and Node Dictionaries
After defining a network in RivGraph with rivgraph.classes.rivnetwork.compute_network()
, two dictionaries will be created:
links and nodes.
This page of the documentation will describe the keys present in these dictionaries.
Note
Not all dictionary key:value pairs are the same length as the number of links or nodes. Some dictionary key:value pairs contain meta-information about the network, or information that only applies to a subset of links/nodes. When the number of key:value pairs matches the number of links or nodes, then they are aligned such that the i’th index of any key:value pair refers to the same link or node.
The Links Dictionary
Links Key Values
N represents the number of links.
key |
type |
length |
description |
---|---|---|---|
id |
orderedSet |
N |
unique link id assigned to each link not in a particular order and not guaranteed to skip some id’s |
conn |
list of 2-element lists |
N |
node ids at link endpoints. After running directionality these are in order i.e. [us_nodeid ds_nodeid] |
idx |
list of lists of ints |
N |
list of the pixel coordinates in index format (via np.ravel_index using the shape of the input binary image) |
n_networks |
int |
1 |
number of networks identified |
parallels |
list of lists |
varies |
each sublist contains all link ids of links forming a parallel set; i.e. links that start and end at the same node. |
wid_pix |
list of np.arrays |
N |
width at each pixel of each link (pixels defined by idx) |
len |
list |
N |
length of each link |
wid |
list |
N |
average width of each link |
len_adj |
list |
N |
length of each link adjusted for accuracy |
wid_adj |
list |
N |
width of each link adjusted for accuracy |
key |
type |
length |
description |
---|---|---|---|
certain |
np.array |
N |
1 if the link’s direction has been set else 0 |
certain_order |
np.array |
N |
describes the order in which links were set. Lower certain_order corresponds to earlier-set links. |
certain_alg |
np.array |
N |
algorithm id of the algorithm ultimately used to set the link direction |
guess |
list of lists |
N |
guesses of the upstream node id for each link; corresponds to guess_alg |
guess_alg |
list of lists |
N |
algorithm id used to compute guess; corresponds to guess |
key |
type |
length |
description |
---|---|---|---|
maxang |
np.array |
N |
??? |
cldists |
np.array |
N |
number of mesh-generated transects each link intersects |
clangs |
np.array |
N |
angle of the link with respect to the valley centerline in radians |
wid_pctdiff |
np.array |
N |
percent difference between the widest and narrowest pixels in a link |
key |
type |
length |
description |
---|---|---|---|
slope |
list |
N |
slope computed from synthetic DEM; note that this has no physical basis and should not be interpreted as actual link slope |
Accessing Link Values
For example, if you know the link_id of the link you are interested in, you can get its index with links['id'].index(link_id)
.
The Nodes Dictionary
Nodes Key Values
M represents the number of nodes.
key |
type |
length |
description |
---|---|---|---|
id |
orderedSet |
M |
unique node id assigned to each node not in a particular order and not guaranteed to skip some id’s |
conn |
list of lists |
M |
link ids of all links connected to this node |
idx |
list of lists of ints |
M |
list of the pixel coordinates in index format (via np.ravel_index using the shape of the input binary image) |
inlets |
list of ints |
varies |
node ids of all nodes identified as inlets |
outlets |
list of ints |
varies |
node ids of all nodes identified as outlets |
int_angle |
np.array |
M |
most interior angle of links connected to each node in degrees; computed via |
jtype |
np.array |
M |
junction type; either ‘c’ (confluence) or ‘b’ (bifurcation); computed via |
width_ratio |
np.array |
M |
ratio of wider link/narrower link for the two links used to compute int_angle; computed via |
Accessing Node Values
For example, if you wish to find the links connected to node_id == 66
, you can use nodes['conn'][nodes['id'].index(66)]
.