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

Matt.Wilkie at yukon.ca Matt.Wilkie at yukon.ca
Thu Oct 14 11:23:21 PDT 2021


Re: Problem 1 - Following a thread “Unicode support in GDAL”[0] I tried adding “ENCODING=UTF-8” but the COG driver doesn’t support it. So I’ve taken the practical route out of just spelling out micron instead of using the symbol.

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.

[0]: https://lists.osgeo.org/pipermail/gdal-dev/2021-August/054500.html

-Matt

From: gdal-dev <gdal-dev-bounces at lists.osgeo.org<mailto:gdal-dev-bounces at lists.osgeo.org>> On Behalf Of Matt.Wilkie at yukon.ca<mailto:Matt.Wilkie at yukon.ca>
Sent: October 13, 2021 4:39 PM
To: gdal-dev at lists.osgeo.org<mailto:gdal-dev at lists.osgeo.org>
Subject: [gdal-dev] Python gdal.Translate(...) and unicode in Band Descriptions.

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/20211014/62d4f2e7/attachment-0001.html>


More information about the gdal-dev mailing list