-
|
I have an xarray.DataArray with 5 bands, that I want to save as a tiff. But I want to preserve the band names. The way I do this is convert the DataArray to a Dataset first. That helps preserving the band names in the tiff file. However in that case the no_data value is lost. And I can't use rio.write_crs on a Dataset. Is there a easy solution to this? Saving this (dataarray.rio.write_nodata(0).to_dataset(dim='band')) keeps band names but not no_data. Thanks. |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
|
Does this work? dataset = dataarray.to_dataset(dim='band')
for data_var in dataset.data_vars:
dataset[data_var].rio.write_nodata(0, inplace=True) |
Beta Was this translation helpful? Give feedback.
Does this work?