Skip to content

How to exclude NoData values when calculating the flow direction of DEM? #256

@mht2953658596

Description

@mht2953658596

When using PyShed to calculate the flow direction of DEM, I found that the flow direction was also calculated for areas where DEM values were NoData. How can I avoid this situation?

When I set NoData using the following code:

nodata = gdal.Open(raster_path)tGetRasterBand(1).ReadAsArray().GetNoDataValue()
grid = Grid.from_raster(raster_path, nodata=nodata)
dem = grid.read_raster(self.raster_path, band=1, nodata=grid.nodata)
flooded_dem = grid.fill_depressions(dem)
inflated_dem = grid.resolve_flats(flooded_dem)
fdir = grid.flowdir(inflated_dem)

it reports the following error:

image

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions