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

Even Rouault even.rouault at spatialys.com
Thu Oct 14 12:10:39 PDT 2021


you could do something along:

tmp_vrt = gdal.Translate("", src_ds, format = 'VRT')

call SetColorInterpretation() / SetDescription() on tmp_vrt

gdal.Translate(dstname, tmp_vrt, format = 'COG', ...)


Le 14/10/2021 à 20:45, Matt.Wilkie at yukon.ca a écrit :
>> 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.
>
>
> _______________________________________________
> gdal-dev mailing list
> gdal-dev at lists.osgeo.org
> https://lists.osgeo.org/mailman/listinfo/gdal-dev

-- 
http://www.spatialys.com
My software is free, but my time generally not.



More information about the gdal-dev mailing list