M-6: non-spatial coords dropped by reproject() and merge()
In xrspatial/reproject/__init__.py, the output DataArray is built with only {ydim: y_coords, xdim: x_coords} (plus the band coord on the 3D path). Any other coord on the input is dropped:
- scalar coords (e.g. a single
time timestamp)
- non-dimension coords (e.g.
spatial_ref from rioxarray)
- any extra dim coord that does not apply to the rebuilt grid
This affects both reproject() (around the result_data.ndim == 3 / 2D branches) and merge() (the final xr.DataArray construction).
Fix: after assigning y/x (and band) coords, copy any remaining coord whose dims do not include the spatial ydim or xdim. Coords aligned to ydim/xdim should still be dropped because their values are stale after the grid is rebuilt.
M-8: y-axis output direction is undocumented
_make_output_coords in xrspatial/reproject/_grid.py always emits y from top - res/2 down to bottom + res/2, so a y-ascending input produces a y-descending output. This is the standard raster convention (top-down, north-up) and is the right behaviour, but it is not stated in the reproject() or merge() docstrings, and the existing test_south_up_matches_north_up only checks .values equality.
Fix: add a sentence to the Returns section of both docstrings.
Plan
- Update the 2D and 3D branches of
reproject() to carry forward non-spatial coords.
- Update
merge() to do the same from the first input raster.
- Document the y-descending output convention in both docstrings.
- Add
TestCoordsPreservation covering scalar time, non-dim string coord, stale y-aligned coord drop, band coord round-trip, merge scalar coord, and y-descending output for numpy and dask backends.
M-6: non-spatial coords dropped by
reproject()andmerge()In
xrspatial/reproject/__init__.py, the outputDataArrayis built with only{ydim: y_coords, xdim: x_coords}(plus the band coord on the 3D path). Any other coord on the input is dropped:timetimestamp)spatial_reffrom rioxarray)This affects both
reproject()(around theresult_data.ndim == 3/ 2D branches) andmerge()(the finalxr.DataArrayconstruction).Fix: after assigning y/x (and band) coords, copy any remaining coord whose dims do not include the spatial ydim or xdim. Coords aligned to ydim/xdim should still be dropped because their values are stale after the grid is rebuilt.
M-8: y-axis output direction is undocumented
_make_output_coordsinxrspatial/reproject/_grid.pyalways emits y fromtop - res/2down tobottom + res/2, so a y-ascending input produces a y-descending output. This is the standard raster convention (top-down, north-up) and is the right behaviour, but it is not stated in thereproject()ormerge()docstrings, and the existingtest_south_up_matches_north_uponly checks.valuesequality.Fix: add a sentence to the
Returnssection of both docstrings.Plan
reproject()to carry forward non-spatial coords.merge()to do the same from the first input raster.TestCoordsPreservationcovering scalartime, non-dim string coord, stale y-aligned coord drop, band coord round-trip, merge scalar coord, and y-descending output for numpy and dask backends.