Ejemplo n.º 1
0
def prune_delta(links, nodes, shoreline_shp, inlets_shp, gdobj):
    """
    Prune a delta network.

    Clips a delta channel network given an inlet and shoreline shapefile and
    removes spurious links.

    Parameters
    ----------
    links : dict
        stores the network's links and their properties
    nodes : dict
        stores the network's nodes and their properties
    shoreline_shp : str
        path to the shoreline shapefile (polyline)
    inlets_shp : str
        path to the shapefile of inlet locations (point shapefile)
    gdobj : osgeo.gdal.Dataset
        gdal object corresponding to the georeferenced input binary channel
        mask

    Returns
    -------
    links : dict
        updated links dictionary
    nodes : dict
        updated nodes dictionary

    """
    # Get inlet nodes
    nodes = find_inlet_nodes(nodes, inlets_shp, gdobj)

    # Remove spurs from network (this includes valid inlets and outlets)
    links, nodes = lnu.remove_all_spurs(links,
                                        nodes,
                                        dontremove=list(nodes['inlets']))

    # Clip the network with a shoreline polyline, adding outlet nodes
    links, nodes = clip_by_shoreline(links, nodes, shoreline_shp, gdobj)

    # Remove spurs from network (this includes valid inlets and outlets)
    links, nodes = lnu.remove_all_spurs(links,
                                        nodes,
                                        dontremove=list(nodes['inlets']) +
                                        list(nodes['outlets']))

    # Remove sets of links that are disconnected from inlets/outlets except for
    # a single bridge link (effectively re-pruning the network)
    links, nodes = lnu.remove_disconnected_bridge_links(links, nodes)

    # # Add artificial nodes where necessary
    # links, nodes = lnu.add_artificial_nodes(links, nodes, gdobj)

    # Remove one-node links
    links, nodes = lnu.remove_single_pixel_links(links, nodes)

    # Find parallel links
    links, nodes = lnu.find_parallel_links(links, nodes)

    return links, nodes
Ejemplo n.º 2
0
def prune_network(links, nodes, shoreline_shp, inlets_shp, skel_gdobj):

    # Get inlet nodes
    nodes = find_inlet_nodes(nodes, inlets_shp, skel_gdobj)

    # Remove spurs from network (this includes valid inlets and outlets)
    links, nodes = lnu.remove_all_spurs(links,
                                        nodes,
                                        dontremove=list(nodes['inlets']))

    # Clip the network with a shoreline polyline, adding outlet nodes
    links, nodes = clip_by_shoreline(links, nodes, shoreline_shp, skel_gdobj)

    # Add artificial nodes where necessary
    links, nodes = lnu.add_artificial_nodes(links, nodes, skel_gdobj)

    # Remove one-node links
    links, nodes = lnu.remove_single_pixel_links(links, nodes)

    return links, nodes
Ejemplo n.º 3
0
def prune_river(links, nodes, exit_sides, Iskel, gdobj):
    """Prune river network."""
    # Get inlet nodes
    nodes = find_inlet_outlet_nodes(links, nodes, exit_sides, Iskel)

    # Remove spurs from network (this includes valid inlets and outlets unless
    # specified not to remove)
    links, nodes = lnu.remove_all_spurs(links,
                                        nodes,
                                        dontremove=list(nodes['inlets'] +
                                                        nodes['outlets']))

    # # Add artificial nodes where necessary
    # links, nodes = lnu.add_artificial_nodes(links, nodes, gdobj)
    links, nodes = lnu.find_parallel_links(links, nodes)

    # Remove sets of links that are disconnected from inlets/outlets except
    # for a single bridge link (effectively re-pruning the network)
    links, nodes = lnu.remove_disconnected_bridge_links(links, nodes)

    # Remove one-pixel links
    links, nodes = lnu.remove_single_pixel_links(links, nodes)

    return links, nodes