landlab.graph.quantity.of_link¶
- get_angle_of_link(graph, out=None)[source]¶
Get angles of links in a graph.
- Parameters:
graph (Graph) – A Graph.
- Returns:
ndarray of float – Angle of each link as measured in radians from link tail to head.
out (ndarray of float, optional) – Buffer to place output.
Examples
>>> import numpy as np >>> from landlab.graph import UniformRectilinearGraph >>> from landlab.graph.quantity.of_link import get_angle_of_link
>>> graph = UniformRectilinearGraph((2, 2)) >>> get_angle_of_link(graph) * 180.0 / np.pi array([ 0., 90., 90., 0.])
>>> angles = np.empty(graph.number_of_links, dtype=float) >>> rtn = get_angle_of_link(graph, out=angles) >>> angles is rtn True
- get_midpoint_of_link(graph, out=None)[source]¶
Get xy position of the midpoint of links.
- Parameters:
graph (Graph) – A Graph.
out (ndarray of float, optional) – Buffer to place output.
- Returns:
Coordinates of link midpoints.
- Return type:
ndarray of float, shape (n_links, 2)
Examples
>>> import numpy as np >>> from landlab.graph import UniformRectilinearGraph >>> from landlab.graph.quantity.of_link import get_midpoint_of_link
>>> graph = UniformRectilinearGraph((2, 2)) >>> get_midpoint_of_link(graph) array([[0.5, 0. ], [0. , 0.5], [1. , 0.5], [0.5, 1. ]])
>>> points = np.empty((graph.number_of_links, 2), dtype=float) >>> rtn = get_midpoint_of_link(graph, out=points) >>> points is rtn True