Skip to content

ENH: Add keep_encoding to global options #5336

Closed
@snowman2

Description

@snowman2

Is your feature request related to a problem? Please describe.
https://corteva.github.io/rioxarray/stable/getting_started/manage_information_loss.html

Original data:

rds.green.attrs, rds.green.encoding
({'nodata': 0, 'units': ('DN', 'DN')},
 {'dtype': 'float64',
  'grid_mapping': 'spatial_ref',
  'scale_factor': 1.0,
  'add_offset': 0.0,
  '_FillValue': nan,
  'source': 'netcdf:../../test/test_data/input/PLANET_SCOPE_3D.nc:green'})
with xarray.set_options(keep_attrs=True):
    new_ds = rds.green + rds.green
new_ds.attrs, new_ds.encoding
{'nodata': 0, 'units': ('DN', 'DN')}, {}

Describe the solution you'd like

with xarray.set_options(keep_attrs=True, keep_encoding=True):
    new_ds = rds.green + rds.green
new_ds.attrs, new_ds.encoding
({'nodata': 0, 'units': ('DN', 'DN')},
 {'dtype': 'float64',
  'grid_mapping': 'spatial_ref',
  'scale_factor': 1.0,
  'add_offset': 0.0,
  '_FillValue': nan,
  'source': 'netcdf:../../test/test_data/input/PLANET_SCOPE_3D.nc:green'})

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions