diff --git a/src/derive_level_paths.py b/src/derive_level_paths.py index d9dbe1a0..97429f86 100755 --- a/src/derive_level_paths.py +++ b/src/derive_level_paths.py @@ -209,9 +209,14 @@ def Derive_level_paths( feature_attribute=branch_id_attribute, outlet_linestring_index=outlet_linestring_index ) - branch_inlets.to_file(branch_inlets_outfile, index=False, driver="GPKG", engine='fiona') + if not branch_inlets.empty: + branch_inlets.to_file(branch_inlets_outfile, index=False, driver="GPKG", engine='fiona') - return stream_network + if stream_network.empty: + print("Sorry, no streams exist and processing can not continue. This could be an empty file.") + sys.exit(FIM_exit_codes.UNIT_NO_BRANCHES.value) # will send a 60 back + else: + return stream_network if __name__ == "__main__": diff --git a/src/stream_branches.py b/src/stream_branches.py index 76ded954..59128147 100755 --- a/src/stream_branches.py +++ b/src/stream_branches.py @@ -1,6 +1,7 @@ #!/usr/bin/env python3 import os +import sys from collections import deque from os.path import isfile, splitext from random import sample @@ -19,6 +20,7 @@ from shapely.strtree import STRtree from tqdm import tqdm +from utils.fim_enums import FIM_exit_codes from utils.shared_variables import PREP_CRS @@ -732,6 +734,12 @@ def select_branches_intersecting_huc(self, wbd, buffer_wbd_streams, out_vector_f if verbose: print("Writing selected branches ...") + if self.empty: + print( + "Sorry, no streams exist and processing can not continue. This could be an empty file." + ) + sys.exit(FIM_exit_codes.UNIT_NO_BRANCHES.value) # will send a 60 back + self.write(out_vector_files, index=False) return self