xdggs.decode

Contents

xdggs.decode#

xdggs.decode(obj, grid_info=None, *, name=None, convention='xdggs', index_options=None, **index_kwargs)#

decode grid parameters and create a DGGS index

Parameters:
  • ds (xarray.Dataset) – The input dataset. Must contain a coordinate for the cell ids with at least the attributes grid_name and level.

  • grid_info (dict or DGGSInfo, optional) – Override the grid parameters on the dataset. Useful to set attributes on the dataset.

  • name (str, default: "cell_ids") – The name of the coordinate containing the cell ids.

  • convention (str, default: "xdggs") – The name of the metadata convention. Built-in conventions are:

    • “xdggs”: the existing xdggs convention. name points to the coordinate containing cell ids, and which has all the grid metadata. The name parameter defaults to "cell_ids".

    • “cf”: the upcoming CF convention standardization. While the convention extension is specialized on healpix for now, the decoder can work with other DGGS as well. For this, all metadata lives on a variable with a grid_mapping_name attribute, and the cell ids coordinate is indicated by the coordinates attribute on data variables / other coordinates (this can be overridden by the name parameter).

  • index_options, **index_kwargs (dict, optional) – Additional options to forward to the index.

Returns:

decoded (xarray.DataArray or xarray.Dataset) – The input dataset with a DGGS index on the cell id coordinate.