Skip to content

Commit

Permalink
feat: migrating merge raster files to defence.py
Browse files Browse the repository at this point in the history
  • Loading branch information
ethan-moss committed Sep 18, 2023
1 parent 7190826 commit 2c39071
Showing 1 changed file with 2 additions and 4 deletions.
6 changes: 2 additions & 4 deletions src/transport_performance/utils/raster.py
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@ def merge_raster_files(
"""
# defend against case where the provided input dir does not exist
# note: not able to use `_check_parent_dir_exists()` here since its a dir
if not os.path.exists(input_dir):
raise FileNotFoundError(f"{input_dir} can not be found")

Expand Down Expand Up @@ -105,12 +106,9 @@ def merge_raster_files(
# merge the datasets together
xds_merged = merge_arrays(arrays)

# make output_dir if it does not exist
if not os.path.exists(output_dir):
os.mkdir(output_dir)

# create full filepath for merged tif file and write to disk
MERGED_DIR = os.path.join(output_dir, output_filename)
_check_parent_dir_exists(MERGED_DIR, "MERGED_DIR", create=True)
xds_merged.rio.to_raster(MERGED_DIR)

# get boundaries of inputs and output raster
Expand Down

0 comments on commit 2c39071

Please sign in to comment.