whitebox-tools
whitebox-tools copied to clipboard
python implementation changes the current working directory
calling something like the below seems to change the working directory. This seems like a bad idea (especially without warning the user) as writes to relative file paths don't land as expected. I for one lost some time trying to figure out where my files were going.
pre_working_dir = os.getcwd()
if not wbt.cost_distance(wse_fp,cost_fp,
os.path.join(out_dir, f'01_outAccum.tif'),
backlink_fp) == 0:
raise IOError('cost_distance')
assert pre_working_dir==os.getcwd(), 'directory changed unexpectedly'