<html><head></head><body><div>
            
     
     
       
         <meta charset="utf-8">
       
       
         <div id="compose-body-wrapper" dir="auto"><div dir="auto"><div 
dir="auto">Hello,</div><div dir="auto">I'm using the GDAL Tools plugin 
within QGIS to plot some raster layers. The snippet reads:</div><div 
dir="auto"><i>        driver_name = 
'GTIFF'</i></div><div dir="auto"><i>        driver = 
gdal.GetDriverByName(driver_name) </i></div><div dir="auto"><i>  
      ...</i></div><div dir="auto"><i>      
  gdal_ds = driver.Create("my_arguments") </i></div><div 
dir="auto"><i>        
gdal_ds.SetProjection("my_projection")</i></div><div dir="auto"><i>  
      
gdal_ds.SetGeoTransform("my_geo_transform")</i></div><div 
dir="auto"><i>        for band_idx in range(1, times + 
1):</i></div><div dir="auto"><i>            
band = gdal_ds.GetRasterBand(band_idx) </i></div><div 
dir="auto"><i>            
band.SetNoDataValue(no_data)</i></div><div dir="auto"><i>    
        band.SetDescription(time_step)</i></div><div 
dir="auto"><i>            data = var[band_idx 
- 1]</i></div><div dir="auto"><i>            
data = ma.getdata(data)</i></div><div dir="auto"><i>      
      band.WriteArray(data.astype(np_dtype, 
copy=False))</i></div><div dir="auto"><i>      
 gdal_ds.FlushCache()</i></div><div dir="auto">This works without any 
problem and plots the raster in greys. However, I need the plot to be 
colored so I modified the code based on some posts, which now 
reads:  </div><div dir="auto"><i>        
gdal_ds = driver.Create(out_path, cols, rows, times, 
gdal.GDT_UInt16) </i></div><div dir="auto"><i>      
  gdal_ds.SetProjection("my_projection")</i></div><div 
dir="auto"><i>        
gdal_ds.SetGeoTransform("my_geo_transform")</i></div><div 
dir="auto"><i>        for band_idx in range(1, times + 
1):</i></div><div dir="auto"><i>            
band = gdal_ds.GetRasterBand(band_idx) </i></div><div 
dir="auto"><i>            
band.SetNoDataValue(no_data)</i></div><div dir="auto"><i>    
        band.SetDescription(time_step)</i></div><div 
dir="auto"><i>            data = var[band_idx 
- 1]</i></div><div dir="auto"><i>            
data = ma.getdata(data)</i></div><div dir="auto"><i>      
      data_scaled =  np.interp(data, (data.min(), 
data.max()), (0, 255))</i></div><div dir="auto"><i>      
      data_scaled2 = data_scaled.astype(int)</i></div><div 
dir="auto"><i>            colors = 
gdal.ColorTable()</i></div><div dir="auto"><i>        
    colors.CreateColorRamp(0, (229, 245, 249), 127, (153, 216, 
201))</i></div><div dir="auto"><i>            
colors.CreateColorRamp(127, (153, 216, 201), 254, (44, 162, 
95))</i></div><div dir="auto"><i>            
band.SetRasterColorTable(colors)</i></div><div dir="auto"><i>    
        
band.SetRasterColorInterpretation(gdal.GCI_PaletteIndex)</i></div><div 
dir="auto"><i>            
band.WriteArray(data_scaled2)</i></div><div dir="auto"><i>    
   gdal_ds.FlushCache()</i></div><div dir="auto">The problem is 
that this produces a <font color="#ff0000">RunTimeError: 
SetColorTable()</font> not supported for multi-sample TIFF. I simplified 
this for a single band and QGIS did plot the colored raster. However, this 
is not a solution because production runs will generate dozens (or even 
hundreds) of time step bands. I'm pretty new to GDAL so I'm unsure if this 
is a feature under current development or if there are other alternatives 
so any suggestion on how to proceed would be appreciated.</div><div 
dir="auto">Thank you in advance.</div></div><div 
dir="auto"><br></div></div>
       
     
   
         </div></body></html>