Skip to content

Add kernel density estimation (KDE) for point-to-raster conversion #1143

@brendancol

Description

@brendancol

KDE is one of the most common GIS operations. Given a set of points, it produces a continuous density surface on a raster grid. It comes up all the time in crime mapping, epidemiology, species distribution modeling, and event heatmaps.

Right now xarray-spatial has rasterize() which burns discrete values onto a grid, but there's nothing for producing continuous density surfaces from point data. That's a pretty significant gap.

Scope

Core KDE

  • KDE with configurable bandwidth and kernel shape (Gaussian, Epanechnikov, quartic)
  • Automatic bandwidth selection via Silverman's rule and cross-validation
  • Optional population-weighted KDE (each point carries a weight)

Line density

  • Same concept but for linear features rather than points

API

  • Input: arrays of x/y coordinates (and optional weights), plus a target raster grid specification (extent, resolution, or a template DataArray)
  • Output: xarray DataArray with density values

Implementation notes

GPU acceleration is straightforward here since each output pixel independently sums contributions from all input points. This is an embarrassingly parallel workload that maps well to CUDA kernels.

For large point datasets with small bandwidths, a spatial index (grid-based binning) can avoid the O(n*m) brute force. On GPU, a simple grid hash is enough.

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions