Raster.filter() or ds.rst.filter()#
- RasterBase.filter(method, size=None, sigma=1, engine='scipy', outlier_threshold=2.0, mp_config=None, coverage=None, kernel_shape=None, **kwargs)[source]#
Apply a filter to the raster array.
A Reducer can select its cells with GridNeighbours, for example
filter(Mean(neighborhood=GridNeighbours(size=5, shape="circular", coverage="fractional"))). Its configured window is used unless size, kernel_shape or coverage is supplied.- Parameters:
method (
str|Reducer|Callable[...,NDArray[floating[Any] |integer[Any]]]) – The filter to apply. Can be a string (“gaussian”, “median”, “mean”, “max”, “min”, “distance”) for built-in filters, or a custom callable that takes a 2D ndarray and returns one.mp_config (
MultiprocConfig|None) – Multiprocessing configuration.coverage (
Literal['center','all_touched','fractional'] |None) – Select cells by center, include all touched cells, or weight by covered area.kernel_shape (
Literal['square','circular'] |None) – Use a square or circular window for a Reducer.sigma (
int) – Optional standard deviation for Gaussian filtering. Only used when method=”gaussian”.engine (
Literal['scipy','numba']) – Optional engine to use for filtering, either “scipy” (default) or “numba”. Only used with built-in filters.outlier_threshold (
float) – The minimum difference abs(array - mean) for a pixel to be considered an outlier. Only used when method=”distance”.
:param kwargs : Additional keyword arguments passed to the underlying filter implementation.
- Return type:
TypeVar(RasterType, bound= RasterBase)- Returns:
A new Raster instance with the filtered data (or None if inplace).
- Raises:
ValueError – If the filter name is not one of the predefined options.
TypeError – If method is neither a string nor a callable.