-
Notifications
You must be signed in to change notification settings - Fork 86
Add kernel density estimation (KDE) for point-to-raster conversion #1143
Description
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.