I think it makes sense to upstream the affine transform pieces to Xarray, since it's probably also used in bioimaging for example.
One blocker might be the use of the affine package, though it'd probably fine as an optional dependency.
@benbovy can you open an issue on the Xarray tracker about moving this piece upstream?