ds.rst.filter() or Raster.filter()#
- RasterBase.filter(method, window=None, sigma=1, engine=None, outlier_threshold=2.0, mp_config=None, coverage=None, window_shape=None, backend='auto', method_kwargs=None, **kwargs)[source]#
Apply a filter to the raster array.
Choose a built-in filter with method and set its neighborhood with window, window_shape and coverage. Advanced callers can supply a Reducer or custom callable. A Reducer can select cells with GridNeighbours, for example
filter(Mean(neighborhood=GridNeighbours(size=5, shape="circular", coverage="fractional"))). Its configured window is used unless window, window_shape or coverage is supplied. size and kernel_shape remain deprecated aliases for window and window_shape.- Parameters:
method (
Literal['nearest','linear','bilinear','cubic','cubic_convolution','cubic_spline','lanczos','quintic','slinear','pchip','splinef2d','idw','inv_dist','kriging','mean','average','sum','median','med','quantile','q1','q3','mode','minimum','min','maximum','max','range','count','stdev','std','standard_deviation','rms','rmse','average_distance','average_distance_pts'] |Literal['gaussian','distance'] |Reducer|Callable[...,NDArray[floating[Any] |integer[Any]]]) – Built-in filter or statistic name (e.g. “gaussian”, “median”, “mean”, “max”, “min”, “distance”), a Reducer, or a custom callable that takes a 2D ndarray and returns one.backend (
Literal['auto','gdal','scipy','numba','gstools','gpytorch']) – “auto” uses SciPy; “scipy” and “numba” select the calculation explicitly.method_kwargs (
dict[str,Any] |None) – Settings for a named statistic, such as a quantile q.window (
int|None) – Window size for filter, in source pixels.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.window_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'] |None) – Legacy alias for backend (“scipy” or “numba”).outlier_threshold (
float) – The minimum difference abs(array - mean) for a pixel to be considered an outlier. Only used when method=”distance”.kwargs (
Any) – Additional keyword arguments passed to the underlying filter implementation.
- Return type:
RasterType- 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.