landlab.grid.create_network¶
Created on Tue Feb 2 17:50:09 2021
@author: sahrendt
- class AlongChannelSpacingAtLeast[source]¶
Bases:
SpacingAtLeast
Remove segment nodes to ensure a minimum per-node along-channel spacing.
- __init__(xy_of_node, spacing=1.0)¶
- Parameters:
xy_of_node (Buffer | _SupportsArray[dtype[Any]] | _NestedSequence[_SupportsArray[dtype[Any]]] | bool | int | float | complex | str | bytes | _NestedSequence[bool | int | float | complex | str | bytes])
spacing (Buffer | _SupportsArray[dtype[Any]] | _NestedSequence[_SupportsArray[dtype[Any]]] | bool | int | float | complex | str | bytes | _NestedSequence[bool | int | float | complex | str | bytes])
- Return type:
None
- __new__(**kwargs)¶
- calc_distance_along_segment(segment)¶
Calculate the along-channel distance of a segment.
- class AtMostNodes[source]¶
Bases:
SegmentReducer
Reduce a segment to a maximum number of nodes.
- __new__(**kwargs)¶
- reduce(segment)[source]¶
Reduce the number of nodes in a channel segment.
- Parameters:
segment (Buffer | _SupportsArray[dtype[Any]] | _NestedSequence[_SupportsArray[dtype[Any]]] | bool | int | float | complex | str | bytes | _NestedSequence[bool | int | float | complex | str | bytes])
- Return type:
Buffer | _SupportsArray[dtype[Any]] | _NestedSequence[_SupportsArray[dtype[Any]]] | bool | int | float | complex | str | bytes | _NestedSequence[bool | int | float | complex | str | bytes]
- class ChannelSegment[source]¶
Bases:
object
A channel segment.
- Parameters:
nodes (iterable of int) – The nodes of the channel, listed from downstream to upstream.
- __new__(**kwargs)¶
- property downstream¶
The downstream segment.
- property downstream_node¶
The most downstream node of the channel segment.
- property nodes¶
The nodes of the segment, from downstream to upstream.
- property upstream¶
The upstream segments.
- property upstream_node¶
The most upstream node of the channel segment.
- class ChannelSegmentConnector[source]¶
Bases:
object
Connect channel segments to form a network.
ChannelSegmentConnector(channel1, channel2, …)
- __new__(**kwargs)¶
- property orphans¶
Channel segments that are not connected to the main network.
- property root¶
The root (most downstream) channel of the network.
- exception DisconnectedSegmentError[source]¶
Bases:
Exception
Raise this exception if a channel segment cannot be connected to a network.
- __init__(*args, **kwargs)¶
- __new__(**kwargs)¶
- add_note()¶
Exception.add_note(note) – add a note to the exception
- args¶
- with_traceback()¶
Exception.with_traceback(tb) – set self.__traceback__ to tb and return self.
- class JustEndNodes[source]¶
Bases:
SegmentReducer
Reduce a segment to just its end nodes.
- __init__()¶
- __new__(**kwargs)¶
- class SegmentFieldCollector[source]¶
Bases:
object
Collect field values for each node along segments.
- __call__(segment)[source]¶
Add field values for nodes along a segment to previously collected values.
- __new__(**kwargs)¶
- property values¶
Field values of all collected nodes.
- class SegmentLinkCollector[source]¶
Bases:
object
Collect links between nodes of segments.
- __new__(**kwargs)¶
- property links¶
Head and tail nodes of all collected links.
- class SegmentNodeCoordinateCollector[source]¶
Bases:
object
Collect xy coordinates for each node along segments.
- __call__(segment)[source]¶
Add coordinates of the nodes of a segment to previously collected coordinates.
- __new__(**kwargs)¶
- property xy_of_node¶
Coordinates of all collected nodes.
- class SegmentNodeReindexer[source]¶
Bases:
object
Reindex nodes along segments.
- __new__(**kwargs)¶
- property nodes¶
Reindexed nodes of all collected nodes.
- class SegmentReducer[source]¶
Bases:
object
Base class for reducing the nodes in a segment.
- __init__()¶
- __new__(**kwargs)¶
- class SpacingAtLeast[source]¶
Bases:
SegmentReducer
Remove segment nodes to ensure a minimum along-channel spacing.
- __init__(xy_of_node, spacing=1.0)¶
- Parameters:
xy_of_node (Buffer | _SupportsArray[dtype[Any]] | _NestedSequence[_SupportsArray[dtype[Any]]] | bool | int | float | complex | str | bytes | _NestedSequence[bool | int | float | complex | str | bytes])
spacing (Buffer | _SupportsArray[dtype[Any]] | _NestedSequence[_SupportsArray[dtype[Any]]] | bool | int | float | complex | str | bytes | _NestedSequence[bool | int | float | complex | str | bytes])
- Return type:
None
- __new__(**kwargs)¶
- calc_distance_to_point(point, points)[source]¶
Find the euclidian distance between one point and a set of points.
- create_network_links(network)[source]¶
Create links between nodes of the channels of a network.
- Parameters:
network (ChannelSegment) – Channel network to create links for.
- Returns:
links – Links for network as (head_node, tail_node).
- Return type:
- create_xy_of_node(network, grid)[source]¶
Create an array of coordinates for each node of a channel network.
- get_channel_segments(grid, divergent_okay=False, minimum_channel_threshold=0.0)[source]¶
Extract channel segments from a grid.
Each segment includes nodes within the segment, upstream segments, and downstream segments.
- Parameters:
grid (RasterModelGrid) – Grid from which to extract channel segments.
divergent_okay (bool, optional) – If
False
, raise an error if the network is divergent (i.e. a channel segment has more than one downstream segments).
- Returns:
segments – Channel segments as lists of grid nodes. Nodes are ordered from downstream to upstream.
- Return type:
- get_node_fields(network, grid, include='*', exclude=None)[source]¶
Get field values for each node of a channel network.
- Parameters:
- Returns:
at_node – Dictionary of node fields for each node of a channel network.
- Return type:
- network_grid_from_raster(grid, reducer=None, include='*', exclude=None, minimum_channel_threshold=0.0)[source]¶
Create a NetworkModelGrid from a RasterModelGrid.
The optional reducer keyword is use to pass a function that reduces the number of nodes in each channel segment. The default is to keep all segment nodes.
- Parameters:
grid (RasterModelGrid object) – A raster grid used to create a network grid
reducer (func, optional) – A function used to reduce the number of nodes in each segment. The default is to include all segment nodes in the created NetworkModelGrid.
include (str, or iterable of str, optional) – Glob-style pattern for field names to include.
exclude (str, or iterable of str, optional) – Glob-style pattern for field names to exclude.
minimum_channel_threshold (float, optional) – Value to use for the minimum drainage area associated with a plotted channel segment from the ChannelProfiler. Default values 10000.
- Returns:
network – NetworkModelGrid object with .at_node[‘rmg_node_value’] attribute listing the RasterModelGrid node ids at each NetworkModelGrid node.
- Return type: