While testing pysheds HAND with an NED DEM, we are getting an unexpected error using the code that ran successfully with SRTM DEM. The method we are using is the same as the one in an earlier ticket: https://github.com/mdbartos/pysheds/issues/113
The DEM information and link to the numpy array is available as indicated in the code lines below.
for l in labels_of_labeled_flood_mask:
#some code to clip dem to rectangular area given the labeled flood mask
#this gives me variables: dem, dem_proj4, dem_gT
#dem = https://www.dropbox.com/s/tvenso6dk0sopp4/dem.npy?dl=0
#dem_proj4 = Proj('+proj=longlat +ellps=GRS80 +towgs84=0,0,0,0,0,0,0 +no_defs', preserve_units=True)
#dem_gT = (-96.630708, 0.0002893451223967838, 0.0, 30.0527557, 0.0, -0.00028934512285926984)
# clip_gT()=(-96.52307161446839, 0.0002893451223967838, 0.0, 29.607742901042442, 0.0, -0.00028934512285926984)
#cip_gT() calculates clipped geoTransform (gT) based on image coordinates, output above.
dirmap = (64, 128, 1, 2, 4, 8, 16, 32)
affine=Affine.from_gdal(*clip_gT(dem_gT, min0, max0, min1, max1, method='image'))
mask=np.ones(dem.shape, dtype=np.bool)
grid=Grid(shape=dem.shape,affine=affine, crs=dem_proj4, mask=mask)
grid.add_gridded_data(dem, data_name='dem',affine=affine, crs=dem_proj4, mask=mask)
grid.fill_depressions('dem', out_name='flooded_dem')
grid.resolve_flats('flooded_dem', out_name='inflated_dem')
grid.flowdir(data='inflated_dem', out_name='dir', dirmap=dirmap)
grid.accumulation(data='dir', dirmap=dirmap, out_name='acc')
grid.compute_hand('dir', 'inflated_dem', grid.acc >100, out_name='hand')
hand_output=grid.view('hand')
The DEM looks normal, and the error happens in the grid.resolve_flats step. Below is the grid.flooded_dem.
Hi,
While testing pysheds HAND with an NED DEM, we are getting an unexpected error using the code that ran successfully with SRTM DEM. The method we are using is the same as the one in an earlier ticket: https://github.com/mdbartos/pysheds/issues/113
The DEM information and link to the numpy array is available as indicated in the code lines below.
The DEM looks normal, and the error happens in the grid.resolve_flats step. Below is the grid.flooded_dem.
Here is the stack trace:
Poking around a bit, it looks like the high_edge_cells is an empty array.
That is generated by
self._get_high_edge_cells(diff, fdir_defined)
. Looks like thehigh_edge_cells_bool
is allFalse
:Any ideas what might be the issue and how to proceed in such a case? Let me know if there is anything else that may help you find the issue.
Best, batu.