Skip to content

Commit

Permalink
Fill output with nodata value.
Browse files Browse the repository at this point in the history
When the border is nodata, it doesn't properly get assigned the nodata_out value.
  • Loading branch information
groutr committed Nov 8, 2023
1 parent 32fb2ef commit 038fa49
Showing 1 changed file with 2 additions and 4 deletions.
6 changes: 2 additions & 4 deletions pysheds/_sgrid.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,17 +10,15 @@
parallel=True,
cache=True)
def _d8_flowdir_numba(dem, dx, dy, dirmap, nodata_cells, nodata_out, flat=-1, pit=-2):
fdir = np.zeros(dem.shape, dtype=np.int64)
fdir = np.full(dem.shape, nodata_out, dtype=np.int64)
m, n = dem.shape
dd = np.sqrt(dx**2 + dy**2)
row_offsets = np.array([-1, -1, 0, 1, 1, 1, 0, -1])
col_offsets = np.array([0, 1, 1, 1, 0, -1, -1, -1])
distances = np.array([dy, dd, dx, dd, dy, dd, dx, dd])
for i in prange(1, m - 1):
for j in prange(1, n - 1):
if nodata_cells[i, j]:
fdir[i, j] = nodata_out
else:
if not nodata_cells[i, j]:
elev = dem[i, j]
max_slope = -np.inf
for k in range(8):
Expand Down

0 comments on commit 038fa49

Please sign in to comment.