-
Notifications
You must be signed in to change notification settings - Fork 86
Add noise handling: SAR speckle filters, cloud masking, gap filling #1146
Description
Problem
Working with real satellite imagery means dealing with noise, clouds, and data gaps before you can do any actual analysis. These preprocessing steps are currently left entirely to the user, even though the underlying operations (focal statistics, mask interpretation, interpolation) are things xarray-spatial already knows how to do.
Proposed scope
SAR speckle filters
Lee, Frost, and Gamma MAP filters for radar imagery. These are focal operations that use adaptive weighting based on local statistics (local mean, variance, number of looks). They fit naturally into the existing map_overlap infrastructure since they operate on moving windows, just like the current focal functions.
Cloud masking utilities
Interpret QA/SCL bands from Sentinel-2 and Landsat to produce clean binary masks. The band encoding differs between sensors and even between collection versions (Landsat 8 vs 9, Sentinel-2 L1C vs L2A), so having a single function that handles the lookup table for each sensor saves users from repeatedly consulting documentation.
Spatial gap filling
Fill masked pixels using focal interpolation from surrounding valid pixels. Inverse-distance weighting within a configurable search radius is the standard approach. This is useful after cloud masking or for filling no-data areas along swath edges.
Temporal gap filling
For time-stacked rasters, interpolate through time at each pixel location to fill cloud-masked dates. Linear interpolation is the baseline; optional smoothing (Savitzky-Golay or similar) handles cases where multiple consecutive dates are missing.
Implementation notes
- SAR filters are the most self-contained piece and could be a good starting point. They're structurally similar to existing focal operations like
mean()but with adaptive weighting, so the implementation pattern is already established. - Cloud masking is mostly lookup table work and doesn't involve heavy computation, but it has ongoing maintenance cost as sensor formats evolve.
- Gap filling (both spatial and temporal) depends on having a mask, so it pairs naturally with the cloud masking work.