xoa.coords.geo_stack

xoa.coords.geo_stack(obj, stack_dim='npts', rename=False, drop=False, reset_index=False, create_index=False)[source]

Stack the dimensions of longitude and latitude coordinates

Note

If already stacked or similar, a simple copy is returned, except if rename is True.

Parameters:
  • obj (xarray.DataArray, xarray.Dataset) – Object with valid longitude and latitude coordinates

  • stack_dim (str) – Name of the new stack dimension

  • rename (False) – Rename longitude to lon and latitude to lat for convenience. If no need to stack, rename the single dimension to stack_dim.

  • drop (bool) – Drop all variables and coordinates that does not contain final stack dimension

  • reset_index (bool) – Remove MultiIndexes that contains lon and lat dimensions before any operations

  • create_index (bool) – Create a MultiIndex when calling stack()

Returns:

xarray.DataArray, xarray.Dataset – Array or dataset with lon and lat stacked. Its “geo_stack” encoding attribute value is set to (stack_dim, lon_dim, lat_dim).