hydromt.gis.DataArray.raster.zonal_stats#
- gis.DataArray.raster.zonal_stats(gdf, stats, all_touched=False)#
Calculate zonal statistics of raster samples aggregated for geometries.
- Parameters:
gdf (
geopandas.GeoDataFrame
) – GeoDataFrame with geometriesstats (
list
ofstr
,callable
) – Statistics to compute from raster values, options include {‘count’, ‘min’, ‘max’, ‘sum’, ‘mean’, ‘std’, ‘median’, ‘q##’}. Multiple percentiles can be calculated using comma-seperated values, e.g.: ‘q10,50,90’. Statistics ignore the nodata value and are applied along the x and y dimension. By default [‘mean’]all_touched (
bool
, optional) – If True, all pixels touched by geometries will used to define the sample. If False, only pixels whose center is within the geometry or that are selected by Bresenham’s line algorithm will be used. By default False.
- Returns:
ojb_out – Output dataset with a variable for each combination of input variable and statistic.
- Return type:
xr.Dataset