<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 generating a raster file with 
GDAL in QGISv3.30. The pseudo-code (with the raster data loaded as 'var') 
reads:</div><div dir="auto">            dims 
= var.dimensions</div><div dir="auto">          
  shape = var.shape</div><div dir="auto">        
    driver_name = 'GTIFF'</div><div dir="auto">    
        driver = 
gdal.GetDriverByName(driver_name) </div><div dir="auto">    
        np_dtype = var.dtype</div><div 
dir="auto">            type_code = 
gdal_array.NumericTypeCodeToGDALTypeCode(np_dtype)</div><div 
dir="auto">            gdal_ds = 
driver.Create(_my_path_, cols, rows, 1, gdal.GDT_Byte) </div><div 
dir="auto">            
gdal_ds.SetProjection(_my_projection_)</div><div dir="auto">    
        
gdal_ds.SetGeoTransform(_my_transformation_)</div><div dir="auto"># 
Creation of the bands and scaled matrix </div><div dir="auto">  
          band = 
gdal_ds.GetRasterBand(1) </div><div dir="auto">      
      band.SetNoDataValue(no_data)</div><div 
dir="auto">            
band.SetDescription(time_step)</div><div dir="auto">      
      data = var[_chosen_index_]</div><div dir="auto">  
          data = ma.getdata(data)</div><div 
dir="auto">            data_scaled =  
np.interp(data, (data.min(), data.max()), (0, 255))</div><div 
dir="auto">            data_scaled2 = 
data_scaled.astype(int) </div><div dir="auto">      
      colors = gdal.ColorTable()</div><div dir="auto">  
          colors.CreateColorRamp(0, (165, 0, 35), 
18, (201, 34, 39))</div><div dir="auto">          
  colors.CreateColorRamp(18, (201, 34, 39), 36, (226, 74, 
51))</div><div dir="auto">            
colors.CreateColorRamp(36, (226, 74, 51), 55, (244, 118, 71))</div><div 
dir="auto">            
colors.CreateColorRamp(55, (244, 118, 71), 73, (250, 163, 91))</div><div 
dir="auto">            
colors.CreateColorRamp(73, (250, 163, 91), 92, (253, 200, 118))</div><div 
dir="auto">            
colors.CreateColorRamp(91, (253, 200, 118), 109, (254, 231, 152))</div><div 
dir="auto">            
colors.CreateColorRamp(109, (254, 231, 152), 127, (254, 254, 
189))</div><div dir="auto">            
colors.CreateColorRamp(127, (254, 254, 189), 145, (231, 245, 
161))</div><div dir="auto">            
colors.CreateColorRamp(145, (231, 245, 161), 163, (198, 230, 
127))</div><div dir="auto">            
colors.CreateColorRamp(163, (198, 230, 127), 181, (162, 216, 
104))</div><div dir="auto">            
colors.CreateColorRamp(181, (162, 216, 104), 200, (114, 194, 
101))</div><div dir="auto">            
colors.CreateColorRamp(200, (114, 194, 101), 218, (64, 170, 90))</div><div 
dir="auto">            
colors.CreateColorRamp(218, (64, 170, 90), 236, (20, 140, 75))</div><div 
dir="auto">            
colors.CreateColorRamp(236, (20, 140, 75), 255, (0, 94, 42))</div><div 
dir="auto">            
band.SetRasterColorTable(colors)</div><div dir="auto">      
      
band.SetRasterColorInterpretation(gdal.GCI_PaletteIndex)</div><div 
dir="auto">            
band.WriteArray(data_scaled2)</div><div dir="auto">      
      gdal_ds.FlushCache()</div><div dir="auto">This has 
been working mostly well except when the color palette is changed to mostly 
greenish with some light yellow. I have been trying to figure out what is 
triggering the change of the color palette for the last 2 weeks (initially 
thinking that it'd be a small thing) but have come up empty. I have checked 
out all variables and types, but everything looks like the same whether it 
uses the given color ramp or the greenish palette. I was wondering if 
anyone has run into the same problem or has any suggestion because I really 
cannot find an explanation.  </div><div 
dir="auto">Thanks.</div><div><br></div></div></div>
       
     
   
         </div></body></html>