Skip to content

Commit

Permalink
fix: add docstring and improve variable naming
Browse files Browse the repository at this point in the history
  • Loading branch information
MDavidson17 committed Sep 25, 2023
1 parent 0b5be2c commit c92bdce
Showing 1 changed file with 12 additions and 6 deletions.
18 changes: 12 additions & 6 deletions scripts/translate_ascii.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,29 +37,35 @@ def main() -> None:

with tempfile.TemporaryDirectory() as tmp_path:
with Pool(concurrency) as p:
ascii_tiffs = p.map(
tiffs = p.map(
partial(
translate_ascii,
tmp_path=tmp_path,
target_dir_path=tmp_path,
),
asc_files,
)
p.close()
p.join()

write_all(inputs=ascii_tiffs, target=arguments.target)
write_all(inputs=tiffs, target=arguments.target)

# copy any sidecar files to target
sidecars = []
for ls in asc_files:
sidecars += find_sidecars(ls, [".prj", ".tfw"])
write_all(inputs=sidecars, target=arguments.target)

def translate_ascii(file: str, target_dir_path: str) -> str:
"""Translates from ascii to geotiff using GDAL
Args:
file: the local file path to translate
target_dir_path: the directory path to write the translated file
def translate_ascii(file: str, tmp_path: str) -> str:
# translate from ascii to geotiff using GDAL
filename = os.path.splitext(os.path.basename(file))[0]
Returns:
full path to translated file
"""
filename = get_file_name_from_path(file)
tiff = os.path.join(target_dir_path, f"{filename}.tiff")
run_gdal(get_ascii_translate_command(), input_file=file, output_file=tiff)
return tiff

Expand Down

0 comments on commit c92bdce

Please sign in to comment.