Skip to content

Add standalone raster resampling (resolution change without reprojection) #1152

@brendancol

Description

@brendancol

Motivation

Changing a raster's resolution (e.g., 10 m to 30 m, or 1 km to 250 m) without changing its CRS is one of the most common raster operations. Right now the only way to do this in xarray-spatial is to call reproject() with the same source and target CRS, which is awkward and unnecessarily slow since it runs the full reprojection pipeline (coordinate transforms, etc.) even though nothing is actually being reprojected.

This is what people use gdalwarp -tr for when the source and target CRS are the same.

Proposed API

resample(da, scale_factor=0.5)          # halve the resolution
resample(da, target_resolution=30.0)    # resample to 30m pixels

Scope

  • Resampling methods: nearest, bilinear, cubic, average, mode (for categorical), min, max, median.
  • Both upsampling and downsampling.
  • Coordinate arrays and spatial attributes should be updated to reflect the new resolution.
  • Nodata handling: nodata pixels must not contribute to weighted methods like average or bilinear interpolation.
  • Dask-friendly: should work as a blockwise or overlap operation depending on the resampling method. Nearest/mode can be blockwise; bilinear/cubic need overlap with appropriate depth.

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