mdbartos / pysheds

:earth_americas: Simple and fast watershed delineation in python.
GNU General Public License v3.0
707 stars 191 forks source link

pixels with no data in resolve_flats #90

Closed Walintik closed 2 years ago

Walintik commented 5 years ago

Hello,

I'm encountering an issue with resolving flats. The generated dem, has pixels where there's no data, although in the original dem, the data exists. How can I solve this? Should I simply reinterpolate the DEM ?

`grid.fill_depressions('dem', out_name='flooded_dem') # Fill depressions in DEM fillView = grid.view('flooded_dem', nodata=np.nan) grid.to_raster(fillView, os.path.join(output_path, 'filled_dem.tif'))

grid.resolve_flats('flooded_dem', out_name='inflated_dem') # Resolve flats in DEM flatView = grid.view('inflated_dem', nodata=np.nan) grid.to_raster(flatView, os.path.join(output_path, 'inflated_dem.tif'))`

Graceful greetings!

jensdebruijn commented 4 years ago

For now I solved this issue by setting these Nan values to an a very high value, ensuring that they drain to a neighboring cell.

grid = Grid.from_raster(topomap, data_name='dem')
grid.fill_depressions('dem', out_name='flooded_dem')
grid.resolve_flats('flooded_dem', out_name='inflated_dem')
grid.inflated_dem[np.isnan(grid.inflated_dem)] = 10000  # setting nan to 10.000 to ensure drainage
grid.flowdir(data='inflated_dem', out_name='dir')
mdbartos commented 2 years ago

Greetings,

Some issues with the resolve_flats function have been resolved in pysheds v0.3. I'd recommend upgrading and reopening this issue if the problem persists. (Note that there are some breaking changes in the new version---namely, the Grid class no longer holds datasets as named parameters. See README for details).