Remote-sensing opensource python library reading optical and SAR sensors, loading and stacking bands, clouds, DEM and spectral indices in a sensor-agnostic way.
I would like to rename the DataArray key in the xr.Dataset object returned by S2Product.load() because I am unable to serialize xr.Dataset to a netCDF file. The xr.Dataset.to_netcdf() raises TypeError: DataArray.name or Dataset key must be either a string or None for serialization to netCDF files. Therefore, I rename the keys from SpectralBandNames objects to strings. When I load from the netcdf file, I would like to rename the string keys to band keys to exactly reconstuct the xr.Dataset object. For this, I call to_band for each str but the to_band returns a list.
Solution:
return a single band instead of a list of bands when to_band is called with a single string
A workaround could be to take the list of all the string keys, convert them all at once in SpectralBandNames and loop on the converted keys.
Wouldn't it be possible?
I would like to rename the DataArray key in the xr.Dataset object returned by
S2Product.load()
because I am unable to serialize xr.Dataset to a netCDF file. The xr.Dataset.to_netcdf() raisesTypeError: DataArray.name or Dataset key must be either a string or None for serialization to netCDF files
. Therefore, I rename the keys from SpectralBandNames objects to strings. When I load from the netcdf file, I would like to rename the string keys to band keys to exactly reconstuct the xr.Dataset object. For this, I call to_band for each str but the to_band returns a list.Solution: return a single band instead of a list of bands when to_band is called with a single string
Could not find an alternative to this