Skip to content

Add standalone raster resampling (#1152)#1172

Merged
brendancol merged 6 commits intomasterfrom
issue-1152
Apr 7, 2026
Merged

Add standalone raster resampling (#1152)#1172
brendancol merged 6 commits intomasterfrom
issue-1152

Conversation

@brendancol
Copy link
Copy Markdown
Contributor

Summary

  • Adds resample() for changing raster cell size without reprojection. Previously the only option was calling reproject() with identical source/target CRS, which runs the full coordinate transform pipeline for no reason.
  • 8 methods: nearest, bilinear, cubic (interpolation, up or down) and average, min, max, median, mode (block aggregation, downsampling only).
  • Nodata pixels don't contaminate neighbors during interpolation (zero-fill/weight-mask trick). Aggregation methods skip NaN.
  • Works on all four backends: numpy, cupy, dask+numpy, dask+cupy. The dask path maps global coordinates per-block so results don't depend on chunk layout.
  • resample(da, scale_factor=0.5) or resample(da, target_resolution=30.0). Tuples work for asymmetric scaling.

Test plan

  • 51 tests: API validation, output geometry, known-value correctness, NaN handling, edge cases (single pixel, single row, non-square, very small scale), Dataset input
  • Dask parity: all 8 methods at multiple scale factors vs numpy
  • CuPy parity: interpolation and aggregation vs numpy
  • Manual check that user guide notebook renders correctly

Closes #1152

Implements raster resampling with 8 methods (nearest, bilinear, cubic,
average, min, max, median, mode) across all 4 backends. Uses
map_coordinates with global coordinate mapping for chunk-consistent
dask results and numba-accelerated block aggregation kernels.
51 tests covering API validation, output geometry, correctness against
known values, NaN handling, edge cases, and backend parity for dask and
cupy paths.
Notebooks 48 and 49 were taken by Sieve Filter, Visibility Analysis,
and KDE after the rebase.
@github-actions github-actions bot added the performance PR touches performance-sensitive code label Apr 7, 2026
@brendancol brendancol merged commit 2918fdc into master Apr 7, 2026
11 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

performance PR touches performance-sensitive code

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add standalone raster resampling (resolution change without reprojection)

1 participant