Skip to content

Commit

Permalink
r.watershed: Null accumulation outside elevation, 0 flow from null fl…
Browse files Browse the repository at this point in the history
…ow (#2221)

* r.watershed: Null accumulation outside elevation

* Null flow amount as 0
  • Loading branch information
HuidaeCho committed Mar 18, 2022
1 parent 2bb77ed commit 5fb7351
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 10 deletions.
10 changes: 4 additions & 6 deletions raster/r.watershed/ram/init_vars.c
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,6 @@ int init_vars(int argc, char *argv[])

/* read elevation input and mark NULL/masked cells */
/* initialize accumulation and drainage direction */
MASK_flag = 0;
do_points = nrows * ncols;
for (r = 0; r < nrows; r++) {
Rast_get_row(fd, elebuf, r, ele_map_type);
Expand Down Expand Up @@ -243,8 +242,7 @@ int init_vars(int argc, char *argv[])
}
Rast_close(fd);
G_free(elebuf);
if (do_points < nrows * ncols)
MASK_flag = 1;
MASK_flag = (do_points < nrows * ncols);

/* read flow accumulation from input map flow: amount of overland flow per cell */
if (run_flag) {
Expand All @@ -253,12 +251,12 @@ int init_vars(int argc, char *argv[])
for (r = 0; r < nrows; r++) {
Rast_get_d_row(fd, dbuf, r);
for (c = 0; c < ncols; c++) {
if (MASK_flag) {
if (Rast_is_d_null_value(&dbuf[c]))
wat[SEG_INDEX(wat_seg, r, c)] = 0.0;
else if (MASK_flag) {
block_value = FLAG_GET(worked, r, c);
if (!block_value)
wat[SEG_INDEX(wat_seg, r, c)] = dbuf[c];
else
wat[SEG_INDEX(wat_seg, r, c)] = 0.0;
}
else
wat[SEG_INDEX(wat_seg, r, c)] = dbuf[c];
Expand Down
4 changes: 0 additions & 4 deletions raster/r.watershed/seg/init_vars.c
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ int init_vars(int argc, char *argv[])
WAT_ALT wa, *wabuf;
ASP_FLAG af, af_nbr, *afbuf;
A_TANB sca_tanb;
char MASK_flag;
void *elebuf, *ptr, *watbuf, *watptr;
int ele_map_type, wat_map_type;
size_t ele_size, wat_size;
Expand Down Expand Up @@ -310,7 +309,6 @@ int init_vars(int argc, char *argv[])

/* read elevation input and mark NULL/masked cells */
G_message("SECTION 1a: Mark masked and NULL cells");
MASK_flag = 0;
do_points = (GW_LARGE_INT) nrows *ncols;

for (r = 0; r < nrows; r++) {
Expand Down Expand Up @@ -402,8 +400,6 @@ int init_vars(int argc, char *argv[])
G_free(watbuf);
}

MASK_flag = (do_points < nrows * ncols);

/* read retention map to adjust flow distribution (AG) */
if (rtn_flag) {
char rtn_value;
Expand Down

0 comments on commit 5fb7351

Please sign in to comment.