<!DOCTYPE html><html><head><title></title><style type="text/css">#qt #qt-qt p.qt-qt-MsoNormal{margin-top:0cm;margin-right:0cm;margin-bottom:0cm;margin-left:0cm;font-size:11pt;font-family:Calibri, sans-serif;}
#qt #qt-qt a:link{color:blue;text-decoration-line:underline;text-decoration-thickness:initial;text-decoration-style:initial;text-decoration-color:initial;}
#qt #qt-qt li.qt-qt-MsoListParagraph{margin-top:0cm;margin-right:0cm;margin-bottom:0cm;margin-left:36pt;font-size:11pt;font-family:Calibri, sans-serif;}
#qt #qt-qt ul{margin-bottom:0cm;}
p.MsoNormal,p.MsoNoSpacing{margin:0}</style></head><body><div style="font-family:Arial;">It's actually pretty easy to test:<br></div><div style="font-family:Arial;"><br></div><div style="font-family:Arial;"><span class="font" style="font-family:menlo, consolas, monospace, sans-serif;">import numpy as np</span><span class="font" style="font-family:menlo, consolas, monospace, sans-serif;"><br></span></div><div style="font-family:Arial;"><span class="font" style="font-family:menlo, consolas, monospace, sans-serif;">import xarray as xr</span><span class="font" style="font-family:menlo, consolas, monospace, sans-serif;"><br></span></div><div style="font-family:Arial;"><span class="font" style="font-family:menlo, consolas, monospace, sans-serif;">from osgeo import gdal</span><span class="font" style="font-family:menlo, consolas, monospace, sans-serif;"><br></span></div><div style="font-family:Arial;"><span class="font" style="font-family:menlo, consolas, monospace, sans-serif;"><br></span></div><div style="font-family:Arial;"><span class="font" style="font-family:menlo, consolas, monospace, sans-serif;">xarray_ds = xr.load_dataset("st4_pr.2017092016.01h", engine="cfgrib")</span><span class="font" style="font-family:menlo, consolas, monospace, sans-serif;"><br></span></div><div style="font-family:Arial;"><span class="font" style="font-family:menlo, consolas, monospace, sans-serif;"># GDAL uses 9999 as NODATA</span><span class="font" style="font-family:menlo, consolas, monospace, sans-serif;"><br></span></div><div style="font-family:Arial;"><span class="font" style="font-family:menlo, consolas, monospace, sans-serif;">xarray_data = np.nan_to_num(xarray_ds.tp.data, nan=9999.0)</span><span class="font" style="font-family:menlo, consolas, monospace, sans-serif;"><br></span></div><div style="font-family:Arial;"><span class="font" style="font-family:menlo, consolas, monospace, sans-serif;">gdal_ds = gdal.Open("st4_pr.2017092016.01h")</span><span class="font" style="font-family:menlo, consolas, monospace, sans-serif;"><br></span></div><div style="font-family:Arial;"><span class="font" style="font-family:menlo, consolas, monospace, sans-serif;">gdal_data = gdal_ds.GetRasterBand(1).ReadAsArray()</span><span class="font" style="font-family:menlo, consolas, monospace, sans-serif;"><br></span></div><div style="font-family:Arial;"><span class="font" style="font-family:menlo, consolas, monospace, sans-serif;"><br></span></div><div style="font-family:Arial;"><span class="font" style="font-family:menlo, consolas, monospace, sans-serif;">>>> gdal_data[80]</span><span class="font" style="font-family:menlo, consolas, monospace, sans-serif;"><br></span></div><div style="font-family:Arial;"><span class="font" style="font-family:menlo, consolas, monospace, sans-serif;">array([9999. , 9999. , 9999. , 9999. , 9999. , 9999. ,</span><span class="font" style="font-family:menlo, consolas, monospace, sans-serif;"><br></span></div><div style="font-family:Arial;"><span class="font" style="font-family:menlo, consolas, monospace, sans-serif;"> 9999. , 9999. , 9999. , 9999. , 9999. , 9999. ,</span><span class="font" style="font-family:menlo, consolas, monospace, sans-serif;"><br></span></div><div style="font-family:Arial;"><span class="font" style="font-family:menlo, consolas, monospace, sans-serif;"> 9999. , 9999. , 9999. , 9999. , 9999. , 9999. ,</span><span class="font" style="font-family:menlo, consolas, monospace, sans-serif;"><br></span></div><div style="font-family:Arial;"><span class="font" style="font-family:menlo, consolas, monospace, sans-serif;"> 9999. , 9999. , 9999. , 9999. , 9999. , 9999. ,</span><span class="font" style="font-family:menlo, consolas, monospace, sans-serif;"><br></span></div><div style="font-family:Arial;"><span class="font" style="font-family:menlo, consolas, monospace, sans-serif;"> 9999. , 9999. , 9999. , 9999. , 9999. , 9999. ,</span><span class="font" style="font-family:menlo, consolas, monospace, sans-serif;"><br></span></div><div style="font-family:Arial;"><span class="font" style="font-family:menlo, consolas, monospace, sans-serif;"> 9999. , 9999. , 9999. , 9999. , 9999. , 9999. ,</span><span class="font" style="font-family:menlo, consolas, monospace, sans-serif;"><br></span></div><div style="font-family:Arial;"><span class="font" style="font-family:menlo, consolas, monospace, sans-serif;"> 9999. , 9999. , 9999. , 9999. , 9999. , 9999. ,</span><span class="font" style="font-family:menlo, consolas, monospace, sans-serif;"><br></span></div><div style="font-family:Arial;"><span class="font" style="font-family:menlo, consolas, monospace, sans-serif;"> 9999. , 9999. , 9999. , 9999. , 9999. , 9999. ,</span><span class="font" style="font-family:menlo, consolas, monospace, sans-serif;"><br></span></div><div style="font-family:Arial;"><span class="font" style="font-family:menlo, consolas, monospace, sans-serif;"> 9999. , 9999. , 9999. , 9999. , 9999. , 9999. ,</span><span class="font" style="font-family:menlo, consolas, monospace, sans-serif;"><br></span></div><div style="font-family:Arial;"><span class="font" style="font-family:menlo, consolas, monospace, sans-serif;"> 9999. , 9999. , 9999. , 9999. , 9999. , 9999. ,</span><span class="font" style="font-family:menlo, consolas, monospace, sans-serif;"><br></span></div><div style="font-family:Arial;"><span class="font" style="font-family:menlo, consolas, monospace, sans-serif;"> 9999. , 9999. , 9999. , 9999. , 9999. , 9999. ,</span><span class="font" style="font-family:menlo, consolas, monospace, sans-serif;"><br></span></div><div style="font-family:Arial;"><span class="font" style="font-family:menlo, consolas, monospace, sans-serif;"> 9999. , 9999. , 9999. , 9999. , 9999. , 9999. ,</span><span class="font" style="font-family:menlo, consolas, monospace, sans-serif;"><br></span></div><div style="font-family:Arial;"><span class="font" style="font-family:menlo, consolas, monospace, sans-serif;"> 9999. , 9999. , 9999. , 9999. , 9999. , 9999. ,</span><span class="font" style="font-family:menlo, consolas, monospace, sans-serif;"><br></span></div><div style="font-family:Arial;"><span class="font" style="font-family:menlo, consolas, monospace, sans-serif;"> 9999. , 9999. , 9999. , 9999. , 9999. , 9999. ,</span><span class="font" style="font-family:menlo, consolas, monospace, sans-serif;"><br></span></div><div style="font-family:Arial;"><span class="font" style="font-family:menlo, consolas, monospace, sans-serif;"> 9999. , 9999. , 9999. , 9999. , 9999. , 9999. ,</span><span class="font" style="font-family:menlo, consolas, monospace, sans-serif;"><br></span></div><div style="font-family:Arial;"><span class="font" style="font-family:menlo, consolas, monospace, sans-serif;"> 9999. , 9999. , 9999. , 9999. , 9999. , 9999. ,</span><span class="font" style="font-family:menlo, consolas, monospace, sans-serif;"><br></span></div><div style="font-family:Arial;"><span class="font" style="font-family:menlo, consolas, monospace, sans-serif;"> 9999. , 9999. , 40.5 , 41.125, 41.75 , 42.5 ,</span><span class="font" style="font-family:menlo, consolas, monospace, sans-serif;"><br></span></div><div style="font-family:Arial;"><span class="font" style="font-family:menlo, consolas, monospace, sans-serif;"> 43. , 26.5 , 26.875, 27. , 29.875, 49.875,</span><span class="font" style="font-family:menlo, consolas, monospace, sans-serif;"><br></span></div><div style="font-family:Arial;"><span class="font" style="font-family:menlo, consolas, monospace, sans-serif;"> 50.375, 41.5 , 41.375, 0. , 0. , 0. ,</span><span class="font" style="font-family:menlo, consolas, monospace, sans-serif;"><br></span></div><div style="font-family:Arial;"><span class="font" style="font-family:menlo, consolas, monospace, sans-serif;"> 0. , 0. , 0. , 0. , 0. , 0. ,</span><span class="font" style="font-family:menlo, consolas, monospace, sans-serif;"><br></span></div><div style="font-family:Arial;"><span class="font" style="font-family:menlo, consolas, monospace, sans-serif;"> 0. , 0. , 0. , 9999. , 9999. , 9999. ,</span><span class="font" style="font-family:menlo, consolas, monospace, sans-serif;"><br></span></div><div style="font-family:Arial;"><span class="font" style="font-family:menlo, consolas, monospace, sans-serif;"> 9999. , 9999. , 9999. , 9999. , 9999. , 9999. ,</span><span class="font" style="font-family:menlo, consolas, monospace, sans-serif;"><br></span></div><div style="font-family:Arial;"><span class="font" style="font-family:menlo, consolas, monospace, sans-serif;"> 0. , 0. , 0. , 0. , 0. , 0. ,</span><span class="font" style="font-family:menlo, consolas, monospace, sans-serif;"><br></span></div><div style="font-family:Arial;"><span class="font" style="font-family:menlo, consolas, monospace, sans-serif;"> 0. , 0. , 0. , 0. , 0. , 0. ,</span><span class="font" style="font-family:menlo, consolas, monospace, sans-serif;"><br></span></div><div style="font-family:Arial;"><span class="font" style="font-family:menlo, consolas, monospace, sans-serif;"> 0. , 0. , 0. , 9999. , 9999. , 9999. ,</span><span class="font" style="font-family:menlo, consolas, monospace, sans-serif;"><br></span></div><div style="font-family:Arial;"><span class="font" style="font-family:menlo, consolas, monospace, sans-serif;"> 9999. , 9999. , 9999. , 9999. , 9999. , 9999. ,</span><span class="font" style="font-family:menlo, consolas, monospace, sans-serif;"><br></span></div><div style="font-family:Arial;"><span class="font" style="font-family:menlo, consolas, monospace, sans-serif;"> 9999. , 9999. , 9999. , 9999. , 9999. , 9999. ,</span><span class="font" style="font-family:menlo, consolas, monospace, sans-serif;"><br></span></div><div style="font-family:Arial;"><span class="font" style="font-family:menlo, consolas, monospace, sans-serif;"> 9999. , 9999. , 9999. , 9999. , 9999. , 9999. ,</span><span class="font" style="font-family:menlo, consolas, monospace, sans-serif;"><br></span></div><div style="font-family:Arial;"><span class="font" style="font-family:menlo, consolas, monospace, sans-serif;"> 9999. , 9999. , 9999. , 9999. , 9999. , 9999. ,</span><span class="font" style="font-family:menlo, consolas, monospace, sans-serif;"><br></span></div><div style="font-family:Arial;"><span class="font" style="font-family:menlo, consolas, monospace, sans-serif;"> 9999. , 9999. , 9999. , 9999. , 9999. , 9999. ,</span><span class="font" style="font-family:menlo, consolas, monospace, sans-serif;"><br></span></div><div style="font-family:Arial;"><span class="font" style="font-family:menlo, consolas, monospace, sans-serif;"> 9999. , 9999. , 9999. , 9999. , 9999. , 9999. ,</span><span class="font" style="font-family:menlo, consolas, monospace, sans-serif;"><br></span></div><div style="font-family:Arial;"><span class="font" style="font-family:menlo, consolas, monospace, sans-serif;"> 9999. , 9999. , 9999. , 9999. , 9999. , 9999. ,</span><span class="font" style="font-family:menlo, consolas, monospace, sans-serif;"><br></span></div><div style="font-family:Arial;"><span class="font" style="font-family:menlo, consolas, monospace, sans-serif;"> 9999. , 9999. , 9999. , 9999. , 9999. , 9999. ,</span><span class="font" style="font-family:menlo, consolas, monospace, sans-serif;"><br></span></div><div style="font-family:Arial;"><span class="font" style="font-family:menlo, consolas, monospace, sans-serif;"> 9999. , 9999. , 9999. , 9999. , 9999. , 9999. ,</span><span class="font" style="font-family:menlo, consolas, monospace, sans-serif;"><br></span></div><div style="font-family:Arial;"><span class="font" style="font-family:menlo, consolas, monospace, sans-serif;"> 9999. ])</span><span class="font" style="font-family:menlo, consolas, monospace, sans-serif;"><br></span></div><div style="font-family:Arial;"><span class="font" style="font-family:menlo, consolas, monospace, sans-serif;">>>> xarray_data[80]</span><span class="font" style="font-family:menlo, consolas, monospace, sans-serif;"><br></span></div><div style="font-family:Arial;"><span class="font" style="font-family:menlo, consolas, monospace, sans-serif;">array([9999. , 9999. , 9999. , 9999. , 9999. , 9999. ,</span><span class="font" style="font-family:menlo, consolas, monospace, sans-serif;"><br></span></div><div style="font-family:Arial;"><span class="font" style="font-family:menlo, consolas, monospace, sans-serif;"> 9999. , 9999. , 9999. , 9999. , 9999. , 9999. ,</span><span class="font" style="font-family:menlo, consolas, monospace, sans-serif;"><br></span></div><div style="font-family:Arial;"><span class="font" style="font-family:menlo, consolas, monospace, sans-serif;"> 9999. , 9999. , 9999. , 9999. , 9999. , 9999. ,</span><span class="font" style="font-family:menlo, consolas, monospace, sans-serif;"><br></span></div><div style="font-family:Arial;"><span class="font" style="font-family:menlo, consolas, monospace, sans-serif;"> 9999. , 9999. , 9999. , 9999. , 9999. , 9999. ,</span><span class="font" style="font-family:menlo, consolas, monospace, sans-serif;"><br></span></div><div style="font-family:Arial;"><span class="font" style="font-family:menlo, consolas, monospace, sans-serif;"> 9999. , 9999. , 9999. , 9999. , 9999. , 9999. ,</span><span class="font" style="font-family:menlo, consolas, monospace, sans-serif;"><br></span></div><div style="font-family:Arial;"><span class="font" style="font-family:menlo, consolas, monospace, sans-serif;"> 9999. , 9999. , 9999. , 9999. , 9999. , 9999. ,</span><span class="font" style="font-family:menlo, consolas, monospace, sans-serif;"><br></span></div><div style="font-family:Arial;"><span class="font" style="font-family:menlo, consolas, monospace, sans-serif;"> 9999. , 9999. , 9999. , 9999. , 9999. , 9999. ,</span><span class="font" style="font-family:menlo, consolas, monospace, sans-serif;"><br></span></div><div style="font-family:Arial;"><span class="font" style="font-family:menlo, consolas, monospace, sans-serif;"> 9999. , 9999. , 9999. , 9999. , 9999. , 9999. ,</span><span class="font" style="font-family:menlo, consolas, monospace, sans-serif;"><br></span></div><div style="font-family:Arial;"><span class="font" style="font-family:menlo, consolas, monospace, sans-serif;"> 9999. , 9999. , 9999. , 9999. , 9999. , 9999. ,</span><span class="font" style="font-family:menlo, consolas, monospace, sans-serif;"><br></span></div><div style="font-family:Arial;"><span class="font" style="font-family:menlo, consolas, monospace, sans-serif;"> 9999. , 9999. , 9999. , 9999. , 9999. , 9999. ,</span><span class="font" style="font-family:menlo, consolas, monospace, sans-serif;"><br></span></div><div style="font-family:Arial;"><span class="font" style="font-family:menlo, consolas, monospace, sans-serif;"> 9999. , 9999. , 9999. , 9999. , 9999. , 9999. ,</span><span class="font" style="font-family:menlo, consolas, monospace, sans-serif;"><br></span></div><div style="font-family:Arial;"><span class="font" style="font-family:menlo, consolas, monospace, sans-serif;"> 9999. , 9999. , 9999. , 13.75 , 14.25 , 14.75 ,</span><span class="font" style="font-family:menlo, consolas, monospace, sans-serif;"><br></span></div><div style="font-family:Arial;"><span class="font" style="font-family:menlo, consolas, monospace, sans-serif;"> 19.125, 32.5 , 30.125, 27.125, 25.5 , 22.25 ,</span><span class="font" style="font-family:menlo, consolas, monospace, sans-serif;"><br></span></div><div style="font-family:Arial;"><span class="font" style="font-family:menlo, consolas, monospace, sans-serif;"> 22.375, 20.25 , 18.375, 16.625, 15.25 , 9999. ,</span><span class="font" style="font-family:menlo, consolas, monospace, sans-serif;"><br></span></div><div style="font-family:Arial;"><span class="font" style="font-family:menlo, consolas, monospace, sans-serif;"> 9999. , 9999. , 9999. , 9999. , 9999. , 9999. ,</span><span class="font" style="font-family:menlo, consolas, monospace, sans-serif;"><br></span></div><div style="font-family:Arial;"><span class="font" style="font-family:menlo, consolas, monospace, sans-serif;"> 9999. , 9999. , 9999. , 9999. , 9999. , 9999. ,</span><span class="font" style="font-family:menlo, consolas, monospace, sans-serif;"><br></span></div><div style="font-family:Arial;"><span class="font" style="font-family:menlo, consolas, monospace, sans-serif;"> 9999. , 9999. , 9999. , 9999. , 9999. , 9999. ,</span><span class="font" style="font-family:menlo, consolas, monospace, sans-serif;"><br></span></div><div style="font-family:Arial;"><span class="font" style="font-family:menlo, consolas, monospace, sans-serif;"> 9999. , 9999. , 9999. , 9999. , 9999. , 9999. ,</span><span class="font" style="font-family:menlo, consolas, monospace, sans-serif;"><br></span></div><div style="font-family:Arial;"><span class="font" style="font-family:menlo, consolas, monospace, sans-serif;"> 9999. , 9999. , 9999. , 9999. , 9999. , 9999. ,</span><span class="font" style="font-family:menlo, consolas, monospace, sans-serif;"><br></span></div><div style="font-family:Arial;"><span class="font" style="font-family:menlo, consolas, monospace, sans-serif;"> 9999. , 9999. , 9999. , 9999. , 9999. , 9999. ,</span><span class="font" style="font-family:menlo, consolas, monospace, sans-serif;"><br></span></div><div style="font-family:Arial;"><span class="font" style="font-family:menlo, consolas, monospace, sans-serif;"> 9999. , 9999. , 9999. , 9999. , 9999. , 9999. ,</span><span class="font" style="font-family:menlo, consolas, monospace, sans-serif;"><br></span></div><div style="font-family:Arial;"><span class="font" style="font-family:menlo, consolas, monospace, sans-serif;"> 9999. , 9999. , 9999. , 9999. , 9999. , 9999. ,</span><span class="font" style="font-family:menlo, consolas, monospace, sans-serif;"><br></span></div><div style="font-family:Arial;"><span class="font" style="font-family:menlo, consolas, monospace, sans-serif;"> 9999. , 9999. , 9999. , 9999. , 9999. , 9999. ,</span><span class="font" style="font-family:menlo, consolas, monospace, sans-serif;"><br></span></div><div style="font-family:Arial;"><span class="font" style="font-family:menlo, consolas, monospace, sans-serif;"> 9999. , 9999. , 9999. , 9999. , 9999. , 9999. ,</span><span class="font" style="font-family:menlo, consolas, monospace, sans-serif;"><br></span></div><div style="font-family:Arial;"><span class="font" style="font-family:menlo, consolas, monospace, sans-serif;"> 9999. , 9999. , 9999. , 9999. , 9999. , 9999. ,</span><span class="font" style="font-family:menlo, consolas, monospace, sans-serif;"><br></span></div><div style="font-family:Arial;"><span class="font" style="font-family:menlo, consolas, monospace, sans-serif;"> 9999. , 9999. , 9999. , 9999. , 9999. , 9999. ,</span><span class="font" style="font-family:menlo, consolas, monospace, sans-serif;"><br></span></div><div style="font-family:Arial;"><span class="font" style="font-family:menlo, consolas, monospace, sans-serif;"> 9999. , 9999. , 9999. , 9999. , 9999. , 9999. ,</span><span class="font" style="font-family:menlo, consolas, monospace, sans-serif;"><br></span></div><div style="font-family:Arial;"><span class="font" style="font-family:menlo, consolas, monospace, sans-serif;"> 9999. , 9999. , 9999. , 9999. , 9999. , 9999. ,</span><span class="font" style="font-family:menlo, consolas, monospace, sans-serif;"><br></span></div><div style="font-family:Arial;"><span class="font" style="font-family:menlo, consolas, monospace, sans-serif;"> 9999. , 9999. , 9999. , 9999. , 9999. , 9999. ,</span><span class="font" style="font-family:menlo, consolas, monospace, sans-serif;"><br></span></div><div style="font-family:Arial;"><span class="font" style="font-family:menlo, consolas, monospace, sans-serif;"> 9999. , 9999. , 9999. , 9999. , 9999. , 9999. ,</span><span class="font" style="font-family:menlo, consolas, monospace, sans-serif;"><br></span></div><div style="font-family:Arial;"><span class="font" style="font-family:menlo, consolas, monospace, sans-serif;"> 9999. , 9999. , 9999. , 9999. , 9999. , 9999. ,</span><span class="font" style="font-family:menlo, consolas, monospace, sans-serif;"><br></span></div><div style="font-family:Arial;"><span class="font" style="font-family:menlo, consolas, monospace, sans-serif;"> 9999. , 9999. , 9999. , 9999. , 9999. , 9999. ,</span><span class="font" style="font-family:menlo, consolas, monospace, sans-serif;"><br></span></div><div style="font-family:Arial;"><span class="font" style="font-family:menlo, consolas, monospace, sans-serif;"> 9999. , 9999. , 9999. , 9999. , 9999. , 9999. ,</span><span class="font" style="font-family:menlo, consolas, monospace, sans-serif;"><br></span></div><div style="font-family:Arial;"><span class="font" style="font-family:menlo, consolas, monospace, sans-serif;"> 9999. , 9999. , 9999. , 9999. , 9999. , 9999. ,</span><span class="font" style="font-family:menlo, consolas, monospace, sans-serif;"><br></span></div><div style="font-family:Arial;"><span class="font" style="font-family:menlo, consolas, monospace, sans-serif;"> 9999. ], dtype=float32)</span><br></div><div style="font-family:Arial;"><br></div><div style="font-family:Arial;">The values are obviously different.<br></div><div style="font-family:Arial;"><br></div><div style="font-family:Arial;">I also tried to convert to NetCDF and open them in QGIS, but they look almost the same (not identical) to me after fixing up the coordinates, so there's probably more at play.<br></div><div style="font-family:Arial;"><br></div><div style="font-family:Arial;">Again, comparing the gdal_translate output with the GRIB data as read by GDAL can't show any issues.<br></div><div style="font-family:Arial;"><br></div><div style="font-family:Arial;">Laurentiu<br></div><div style="font-family:Arial;"><br></div><div>On Thu, Feb 1, 2024, at 13:24, Laurențiu Nicola via gdal-dev wrote:<br></div><blockquote type="cite" id="qt" style=""><div style="font-family:Arial;">Hi Jukka,<br></div><div style="font-family:Arial;"><br></div><div style="font-family:Arial;">If GDAL shuffled around the pixels in that file, you wouldn't be able to notice it by comparing the GRIB and the TIFF, because both would be shuffled.<br></div><div style="font-family:Arial;"><br></div><div style="font-family:Arial;">My suggestion was to convert the GRIB to a NC or even CSV using xarray, then comparing the GDAL output against that.<br></div><div style="font-family:Arial;"><br></div><div style="font-family:Arial;">Laurentiu<br></div><div style="font-family:Arial;"><br></div></blockquote><div style="font-family:Arial;"><br></div></body></html>