xrspatial.kde.line_density#
- xrspatial.kde.line_density(x1: ndarray | list, y1: ndarray | list, x2: ndarray | list, y2: 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 = 'line_density') DataArray[source]#
Compute line density from line-segment data.
Each segment is uniformly sampled and the samples are convolved with the chosen kernel, producing a smooth density surface that represents the concentration of linear features.
- Parameters:
x1 (array-like) – Start and end coordinates of each line segment.
y1 (array-like) – Start and end coordinates of each line segment.
x2 (array-like) – Start and end coordinates of each line segment.
y2 (array-like) – Start and end coordinates of each line segment.
weights (array-like, optional) – Per-segment weights. Defaults to uniform weights of 1.
bandwidth (float or
'silverman') – Kernel bandwidth.'silverman'uses an automatic estimate based on all segment endpoints.kernel (
{'gaussian', 'epanechnikov', 'quartic'}) – Kernel shape.template (xr.DataArray, optional) – Output grid specification (same as
kde()).x_range ((min, max), optional) – Spatial extent.
y_range ((min, max), optional) – Spatial extent.
width (int) – Grid dimensions.
height (int) – Grid dimensions.
name (str) – Name of the output DataArray.
- Returns:
2-D line-density surface.
- Return type:
xr.DataArray