xrspatial.focal.focal_stats(agg, kernel, stats_funcs=['mean', 'max', 'min', 'range', 'std', 'var', 'sum'])[source]

Calculates statistics of the values within a specified focal neighborhood for each pixel in an input raster. The statistics types are Mean, Maximum, Minimum, Range, Standard deviation, Variation and Sum.

  • agg (xarray.DataArray) – 2D array of input values to be analysed.

  • kernel (numpy.array) – 2D array where values of 1 indicate the kernel.

  • stats_funcs (list of string) – List of statistics types to be calculated. Default set to [‘mean’, ‘max’, ‘min’, ‘range’, ‘std’, ‘var’, ‘sum’].


stats_agg – 3D array with dimensions of (stat, y, x) and with values indicating the focal stats.

Return type

xarray.DataArray of same type as agg