xarray-contrib / xdggs

Xarray extension for DGGS
https://xdggs.readthedocs.io
Apache License 2.0
80 stars 14 forks source link

Change grid resolution #18

Open benbovy opened 1 year ago

benbovy commented 1 year ago

It would be useful to have utility methods to change the grid resolution, very much like this and this.

Proposed behavior

This would be pretty similar to Xarray .reindex(), but here DGGS-aware.

When downgrading the resolution, only the cell coordinate would change with child cell ids replaced by their parent cell id at the given resolution. The resulting coordinate has the same size but may have duplicate labels. Users could then perform aggregation with the method of their choice just by using Xarray's .groupby().

When upgrading the resolution, the new cell coordinate has new labels (child cell ids) and the cell dimension may have an increased size, in which case the values of the data variables must be repeated according to the new cell ids along the cell dimension.

These .change_resolution() utility functions might be actually just what we need in order to align, merge or do other operations with multiple Datasets / DataArrays on the same DGGS but at different resolutions. Those are pretty simple and composable functions.

For simplicity, there would be no regridding or resampling involved here. There are two caveats, though: