Open AndrewGuenther opened 1 year ago
A simple solution would be to store an attribute indicating what fields were read from the ENVI namespace and then automatically include those tags on write. The gotcha however is if someone were to add additional attributes or band information they wanted included in the ENVI header they'd need a way to indicate that.
Tracking of the read headers would probably go here: https://github.com/corteva/rioxarray/blob/master/rioxarray/_io.py#L713-L725
One potential solution would be to not flatten the tag structure for general metadata at all. So if a user wanted to include data in the ENVI namespace they could do so this way:
data.attrs["ENVI"]["wavelength units"]
Per band information is a bit more difficult...
When there are multiple bands, the band_tags
key can be added as a list of dicts.
Code Sample
Problem description
In the above code, any tag under the
ENVI
namespace is stripped when the file is written back out. This data reads in just fine, but since the tag structure is flattened on read, that context is then lost on write. So headers likewavelengths
,wavelength units
,acquisition time
, etc are lost.Expected Output
I would expect a subsequent
to_raster
call to look exactly the same as the data passed in.Environment Information
Installation method
poetry