-
Notifications
You must be signed in to change notification settings - Fork 86
Add raster geometric operations (polygon clipping, rotation, seam blending) #1144
Description
Some basic raster manipulation operations are missing from xarray-spatial.
Scope
Polygon clipping
Clip a raster to an arbitrary polygon geometry, not just a bounding box like crop() does. Pixels outside the polygon get masked to nodata. This should accept shapely geometries or coordinate arrays for the clip mask.
This is probably the highest priority item here. It comes up constantly in analysis workflows where you need to extract data for an irregular study area, watershed boundary, administrative unit, etc.
Raster rotation and affine transformation
Arbitrary rotation and affine transforms beyond what reprojection handles. Useful for aligning imagery, rotating to a local coordinate frame, or correcting sensor geometry.
Mosaic with feathered blending
Distance-weighted blending at seam lines when mosaicking overlapping rasters. The existing merge() handles overlap by picking one value, but doesn't blend. Feathered blending produces much better results where rasters overlap, especially when there are brightness or exposure differences between tiles.
Notes
Polygon clipping involves rasterizing the polygon boundary and masking. The existing rasterize() function could potentially be reused for the polygon-to-mask step.