Skip to content

DHyDAMO: consider refactor use of zonal_stats in drreader #189

@DanielTollenaar

Description

@DanielTollenaar

@RuudHurkmans; documentation suggests any rasterio raster will work for land-use: https://hkvconfluence.atlassian.net/wiki/spaces/DHYD/pages/598507527/Landgebruikskaart

This is not true as the land-use needs to be of signed integer type and -999 as nodata value:

lu_rast, lu_affine = self.unpaved.drrmodel.read_raster(landuse, static=True)
lu_counts = zonal_stats(
gpd.GeoDataFrame(catchments),
lu_rast.astype(int),
affine=lu_affine,
categorical=True,
all_touched=all_touched,

Possible fixes:

  1. Include constraints in documentation: het formaat moet een raster zijn met -999 en met een "signed integer" waarde
  2. Fix code, e.g. feeding the raster to the zonal_stats module in stead of the numpy array and the affine as by example in the rasterio documentation: https://pythonhosted.org/rasterstats/manual.html#zonal-statistics

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions