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:
extenstive vs. intensive quantities: The behavior detailed above is correct for intensive quantities (i.e., independent of the cell area) but not for extensive quantities. For the latter, one generic solution could be to optionally output a "weights" coordinate (same dimension than cells) computed from the cell areas and by counting duplicate cell ids. This weights coordinate could then be used to update the values of certain data variables (simple arithmetic) after upgrading the resolution. Unfortunately, in the case of resolution downgrading weighted groupby is not yet supported in Xarray: https://github.com/pydata/xarray/issues/3937.
In some grid systems (like H3), the boundaries of the cells do not match exactly across different resolutions. We might need more advanced regridding in this case, although the solutions above may already provide good enough, first-order approximation.
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: