def do_network(geofile_path=None, title_string=None, layer_string=None, driver_string=None, key_col=None, downstream_col=None, length_col=None, terminal_code=None, verbose=False, debuglevel=0): # NOTE: these methods can lose the "connections" and "rows" arguments when # implemented as class methods where those arrays are members of the class. if verbose: print(title_string) if debuglevel <= -1: print( f'reading -- dataset: {geofile_path}; layer: {layer_string}; fiona driver: {driver_string}' ) geofile = gpd.read_file(geofile_path, driver=driver_string, layer=layer_string) if debuglevel <= -1: print(geofile.head()) geofile_rows = geofile.to_numpy() if debuglevel <= -1: geofile.plot() # Kick off recursive call for all connections and keys (connections) = networkbuilder.get_down_connections( rows=geofile_rows, key_col=key_col, downstream_col=downstream_col, length_col=length_col, verbose=verbose, debuglevel=debuglevel) (all_keys, ref_keys, headwater_keys, terminal_keys, terminal_ref_keys, circular_keys) = networkbuilder.determine_keys( connections=connections, key_col=key_col, downstream_col=downstream_col, terminal_code=terminal_code, verbose=verbose, debuglevel=debuglevel) (junction_keys) = networkbuilder.get_up_connections( connections=connections, terminal_code=terminal_code, headwater_keys=headwater_keys, terminal_keys=terminal_keys, verbose=verbose, debuglevel=debuglevel) return connections, all_keys, ref_keys, headwater_keys \ , terminal_keys, terminal_ref_keys \ , circular_keys, junction_keys
def build_connections_object(geo_file_rows=None, mask_set=None, key_col=None, downstream_col=None, length_col=None, terminal_code=None, verbose=False, debuglevel=0): (connections) = networkbuilder.get_down_connections( rows=geo_file_rows, mask_set=mask_set, key_col=key_col, downstream_col=downstream_col, length_col=length_col, verbose=verbose, debuglevel=debuglevel) (all_keys, ref_keys, headwater_keys, terminal_keys, terminal_ref_keys, circular_keys) = networkbuilder.determine_keys( connections=connections, key_col=key_col, downstream_col=downstream_col, terminal_code=terminal_code, verbose=verbose, debuglevel=debuglevel) (junction_keys, visited_keys, visited_terminal_keys, junction_count) = networkbuilder.get_up_connections( connections=connections, terminal_code=terminal_code, headwater_keys=headwater_keys, terminal_keys=terminal_keys, verbose=verbose, debuglevel=debuglevel) return connections, all_keys, ref_keys, headwater_keys \ , terminal_keys, terminal_ref_keys \ , circular_keys, junction_keys \ , visited_keys, visited_terminal_keys \ , junction_count
def build_connections_object( geo_file_rows=None, mask_set=None, key_col=None, downstream_col=None, length_col=None, terminal_code=None, waterbody_col=None, waterbody_null_code=None, verbose=False, debuglevel=0, ): (connections) = networkbuilder.get_down_connections( rows=geo_file_rows, mask_set=mask_set, key_col=key_col, downstream_col=downstream_col, length_col=length_col, verbose=verbose, debuglevel=debuglevel, ) ( all_keys, ref_keys, headwater_keys, terminal_keys, terminal_ref_keys, circular_keys, ) = networkbuilder.determine_keys( connections=connections # , key_col = key_col # , downstream_col = downstream_col , terminal_code=terminal_code, verbose=verbose, debuglevel=debuglevel, ) ( junction_keys, confluence_segment_set, visited_keys, visited_terminal_keys, junction_count, ) = networkbuilder.get_up_connections( connections=connections, terminal_code=terminal_code, headwater_keys=headwater_keys, terminal_keys=terminal_keys, verbose=verbose, debuglevel=debuglevel, ) waterbody_dict = None waterbody_segments = None waterbody_outlet_set = None waterbody_upstreams_set = None waterbody_downstream_set = None # TODO: Set/pass/identify a proper flag value if waterbody_col is not None: ( waterbody_dict, waterbody_segments, waterbody_outlet_set, waterbody_upstreams_set, waterbody_downstream_set, ) = networkbuilder.get_waterbody_segments( connections=connections, terminal_code=terminal_code, waterbody_col=waterbody_col, waterbody_null_code=waterbody_null_code, verbose=verbose, debuglevel=debuglevel # , debuglevel = -3 ) # TODO: change names to reflect type set or dict return ( connections, all_keys, ref_keys, headwater_keys, terminal_keys, terminal_ref_keys, circular_keys, junction_keys, visited_keys, visited_terminal_keys, junction_count, confluence_segment_set, waterbody_dict, waterbody_segments, waterbody_outlet_set, waterbody_upstreams_set, waterbody_downstream_set, )
[26, 920, 25, 0], [27, 920, 26, 0], [28, 920, 27, 0], ] test_key_col = 0 test_downstream_col = 2 test_length_col = 1 test_terminal_code = -999 debuglevel = 0 verbose = True (test_connections) = networkbuilder.get_down_connections( rows=test_rows, key_col=test_key_col, downstream_col=test_downstream_col, length_col=test_length_col, verbose=True, debuglevel=debuglevel) (test_all_keys, test_ref_keys, test_headwater_keys, test_terminal_keys, test_terminal_ref_keys, test_circular_keys) = networkbuilder.determine_keys( connections=test_connections, key_col=test_key_col, downstream_col=test_downstream_col, terminal_code=test_terminal_code, verbose=True, debuglevel=debuglevel) test_junction_keys = networkbuilder.get_up_connections(