xrspatial.kde.kde#
- xrspatial.kde.kde(x: ndarray | list, y: ndarray | list, *, weights: ndarray | list | None = None, bandwidth: float | str = 'silverman', kernel: str = 'gaussian', template: DataArray | None = None, x_range: Tuple[float, float] | None = None, y_range: Tuple[float, float] | None = None, width: int = 256, height: int = 256, name: str = 'kde') DataArray[source]#
Compute 2-D kernel density estimation from point data.
Each output pixel accumulates weighted kernel contributions from all input points, producing a smooth continuous density surface.
- Parameters:
x (array-like) – 1-D arrays of point coordinates.
y (array-like) – 1-D arrays of point coordinates.
weights (array-like, optional) – Per-point weights. Defaults to uniform weights of 1.
bandwidth (float or
'silverman') – Kernel bandwidth in the same units as x/y.'silverman'(default) uses Silverman’s rule of thumb.kernel (
{'gaussian', 'epanechnikov', 'quartic'}) – Kernel shape.template (xr.DataArray, optional) – If provided, the output matches this array’s shape, extent, and coordinates. x_range, y_range, width, and height are ignored when template is given.
x_range ((min, max), optional) – Spatial extent of the output grid. Defaults to the data extent with 10 %% padding on each side.
y_range ((min, max), optional) – Spatial extent of the output grid. Defaults to the data extent with 10 %% padding on each side.
width (int) – Number of columns and rows in the output grid. Ignored when template is provided.
height (int) – Number of columns and rows in the output grid. Ignored when template is provided.
name (str) – Name of the output DataArray.
- Returns:
2-D density surface.
- Return type:
xr.DataArray