<html><head></head><body><div>
<div dir="auto" id="compose-body-wrapper"><div dir="auto"><div
dir="auto">Hello,</div><div dir="auto">The following
snippet </div><div dir="auto"> band =
gdal_ds.GetRasterBand(1) </div><div dir="auto">
band.SetNoDataValue(no_data)</div><div dir="auto">
...</div><div dir="auto">
band.WriteArray(data_scaled2)</div><div dir="auto">
self.colors = gdal.ColorTable()</div><div dir="auto">
self.colors.CreateColorRamp(0, (0, 0, 0), 255, (0, 0, 0)) #
or a more complex color ramp</div><div dir="auto">
band.SetRasterColorTable(self.colors)</div><div dir="auto">
band.SetRasterColorInterpretation(gdal.GCI_PaletteIndex)</div><div
dir="auto"> gdal_ds.FlushCache()</div><div
dir="auto">generates the RuntimeError 'TIFFSetField?tmp/.../tif: Cannot
modify tag "PhotometricInterpretation" while writing' when executing the
line 'band.SetRasterColorTable(self.colors)' [it traces back to line 5133
in gdal.py]. The confounding thing is that this error has only come up when
upgrading to QGISv3.40 (and its corresponding updated GDAL) as I have run
this code dozens of times with v3.34 (and previously with v3.30) without
any issue. Thanks. </div><div dir="auto"><br></div></div>
</div>
</div></body></html>