def test_artificial_nodes(synthetic_cycles): """Test adding artificial nodes.""" synthetic_cycles.compute_link_width_and_length() links = synthetic_cycles.links nodes = synthetic_cycles.nodes gobj = gdal.Open( os.path.normpath('tests/integration/data/SyntheticCycle/skeleton.tif')) links, nodes = ln_utils.add_artificial_nodes(links, nodes, gobj) # make assertions assert ('arts' in links.keys()) is True assert links['arts'] == [[5, 6, 2]]
def test_add_art_nodes(test_net): """Testing add_artificial_nodes() function.""" gobj = gdal.Open( os.path.normpath( 'tests/integration/data/Colville/Colville_islands_filled.tif')) test_net.skeletonize() test_net.compute_network() # assert no artificial links or nodes before function assert ('arts' in test_net.links) is False assert ('arts' in test_net.nodes) is False # then run the function links, nodes = ln_utils.add_artificial_nodes(test_net.links, test_net.nodes, gobj) # assert that arts is now in nodes and links assert ('arts' in links) is True assert ('arts' in nodes) is True
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