[gdal-dev] Python gdal.Translate(...) and unicode in Band Descriptions.

Matt.Wilkie at yukon.ca Matt.Wilkie at yukon.ca
Thu Oct 14 11:45:37 PDT 2021


> For Problem 2 there’s a new wrinkle: in spite of the warning about being 
> unable to save the .aux.xml info into the source zip sometimes it actually 
> does. I haven’t sorted out when it can and can’t yet.

Solved it: the first time the script is run it saves the Color Interp and Descriptions in the .aux.xml within the zip, and the output image remains Undefined for these fields. In subsequent runs saving the aux fails, and the output image fields for Color Interp and Description are filled out. As I've been using the same input archive repeatedly while testing this sequence was being masked.

So now I'm at the crux I think: how to tell gdal.Translate() to use these metadata without applying them to `data_in.GetRasterBand(1)` and saving first?

Is there a more efficient method than:

~~~
data_in = gdal.Open(vsipath)
gdal.Translate(dstname, vsipath, width=w, height=h, ...)

data_out = gdal.Open(dstname)
    data_out.GetRasterBand(1).SetColorInterpretation(gdal.GCI_RedBand)
    data_out.GetRasterBand(1).SetDescription("Red (0.625 - 0.695 microns)")
    ...

data_in = None
data_out = None
~~~


Matt
Geomatics Developer and Administrator | Environment | T 867-667-8133 | Yukon.ca
Hours: 08:30-16:30, Mon-Wed: Office, Thu: Remote, Fri: Away.




More information about the gdal-dev mailing list