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

Matt.Wilkie at yukon.ca Matt.Wilkie at yukon.ca
Wed Oct 13 16:39:01 PDT 2021


Hi,

The attached python script that reads from a vendor’s SPOT6 distribution archive and creates a cloud optimized geotiff. Reading and writing works, but the band description does not take properly.

Problem 1: The greek letter Mu or Micron<https://theasciicode.com.ar/extended-ascii-code/lowercase-letter-mu-micro-sign-micron-ascii-code-230.html> in description is converted to something else.

In:           Near-Infrared (0.760 µm – 0.890 µm)
Gdalinfo:             Near-Infrared (0.760 ┬╡m ΓÇô 0.890 ┬╡m)

I’m quite sure I’ve seen geotiff descriptions using the micron character before. It was seeing someone else do that the gave me the idea to do the same with our data. Maybe they weren’t using gdal though?

Problem 2: on close it’s trying to update the source. This fails because the source is zipped, which is good because we want to leave the source untouched. However I don’t want to rely on this to keep our house in order. What is the proper way to do this?

Example script run:

$ spot-zip-to-preview process-list-sample.csv preview 2048
/vsizip/A:\Imagery\Work\SPOT-raw\DS_SPOT6_202008182031259_LM1_LM1_LM1_LM1_W137N63_01790.zip/DS_SPOT6_202008182031259_LM1_LM1_LM1_LM1_W137N63_01790/PROD_SPOT6_001/VOL_SPOT6_001_A/IMG_SPOT6_MS_001_A/DIM_SPOT6_MS_202008182031259_SEN_1.XML
0.10..20...50..81..100Warning 6: driver COG does not support creation option PHOTOMETRIC
Warning 1: Unable to save auxiliary information in /vsizip/A:\Imagery\Work\SPOT-raw\DS_SPOT6_202008182031259_LM1_LM1_LM1_LM1_W137N63_01790.zip/DS_SPOT6_202008182031259_LM1_LM1_LM1_LM1_W137N63_01790/PROD_SPOT6_001/VOL_SPOT6_001_A/IMG_SPOT6_MS_001_A/DIM_SPOT6_MS_202008182031259_SEN_1.XML.aux.xml.

The relevant part of the script:

data_in = gdal.Open(vsipath)
#print(data_in.GetMetadata())

if "_MS_" in ds:
    data_in.GetRasterBand(1).SetColorInterpretation(gdal.GCI_RedBand)
    data_in.GetRasterBand(1).SetDescription("Red (0.625 µm – 0.695 µm)")
    data_in.GetRasterBand(2).SetColorInterpretation(gdal.GCI_GreenBand)
    data_in.GetRasterBand(2).SetDescription("Green (0.530 µm – 0.590 µm)")
    data_in.GetRasterBand(3).SetColorInterpretation(gdal.GCI_BlueBand)
    data_in.GetRasterBand(3).SetDescription("Blue (0.455 µm – 0.525 µm)")
    #data_in.GetRasterBand(4).SetColorInterpretation("Gray")
    data_in.GetRasterBand(3).SetDescription("Near-Infrared (0.760 µm – 0.890 µm)")
if "_P_" in ds:
    #data_in.GetRasterBand(1).SetColorInterpretation("Gray")
    data_in.GetRasterBand(1).SetDescription("Panchromatic")

gdal.Translate(dstname, vsipath, width=w, height=h,
    format="COG",
    noData=0,
    creationOptions=options,
    callback=progress_cb,
    callback_data='.')


Thanks in advance for your thoughts.

Matt Wilkie
Geomatics Developer & Administrator
Environment | Technology, Innovation and Mapping
T 867-667-8133 | Yukon.ca<http://yukon.ca/>
Hours: 08:30-16:30, Mon-Wed: Office, Thu: Remote, Fri: Away.

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/gdal-dev/attachments/20211013/ae1754ae/attachment-0001.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: SPOT-zip-to-preview.zip
Type: application/x-zip-compressed
Size: 2089 bytes
Desc: SPOT-zip-to-preview.zip
URL: <http://lists.osgeo.org/pipermail/gdal-dev/attachments/20211013/ae1754ae/attachment-0001.bin>
-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: result-info.txt
URL: <http://lists.osgeo.org/pipermail/gdal-dev/attachments/20211013/ae1754ae/attachment-0001.txt>


More information about the gdal-dev mailing list