Skip to content

Commit

Permalink
updates
Browse files Browse the repository at this point in the history
  • Loading branch information
jblindsay committed Sep 29, 2019
1 parent e7ea1ee commit 6aba2cb
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
6 changes: 4 additions & 2 deletions src/tools/hydro_analysis/fill_depressions.rs
Original file line number Diff line number Diff line change
Expand Up @@ -236,13 +236,15 @@ impl WhiteboxTool for FillDepressions {
// small_num = 1.0 / elev_multiplier as f64;
// }

let small_num = if !flat_increment.is_nan() {
let small_num = if fix_flats && !flat_increment.is_nan() {
flat_increment
} else {
} else if fix_flats {
let min_val = input.configs.minimum;
let elev_digits = ((input.configs.maximum - min_val) as i64).to_string().len();
let elev_multiplier = 10.0_f64.powi((6 - elev_digits) as i32);
1.0_f64 / elev_multiplier as f64
} else {
0f64
};

let mut output = Raster::initialize_using_file(&output_file, &input);
Expand Down
5 changes: 4 additions & 1 deletion whitebox_tools.py
Original file line number Diff line number Diff line change
Expand Up @@ -375,6 +375,7 @@ def list_tools(self, keywords=[]):






##############
Expand Down Expand Up @@ -3463,20 +3464,22 @@ def fill_burn(self, dem, streams, output, callback=None):
args.append("--output='{}'".format(output))
return self.run_tool('fill_burn', args, callback) # returns 1 if error

def fill_depressions(self, dem, output, fix_flats=True, callback=None):
def fill_depressions(self, dem, output, fix_flats=True, flat_increment=None, callback=None):
"""Fills all of the depressions in a DEM. Depression breaching should be preferred in most cases.
Keyword arguments:
dem -- Input raster DEM file.
output -- Output raster file.
fix_flats -- Optional flag indicating whether flat areas should have a small gradient applied.
flat_increment -- Optional elevation increment applied to flat areas.
callback -- Custom function for handling tool text outputs.
"""
args = []
args.append("--dem='{}'".format(dem))
args.append("--output='{}'".format(output))
if fix_flats: args.append("--fix_flats")
if flat_increment is not None: args.append("--flat_increment='{}'".format(flat_increment))
return self.run_tool('fill_depressions', args, callback) # returns 1 if error

def fill_single_cell_pits(self, dem, output, callback=None):
Expand Down

0 comments on commit 6aba2cb

Please sign in to comment.