Opened 7 years ago

Closed 3 years ago

Last modified 3 years ago

#3606 closed defect (fixed)

gdalinfo -stats reports units as Kelvin but displays min/max/avg values in °C

Reported by: shadock Owned by: warmerdam
Priority: normal Milestone: 1.10.2
Component: GDAL_Raster Version: 1.7.0
Severity: normal Keywords: grib


when calling gdalinfo on a GRIB file with temperatures, gdalinfo -stats reports units as Kelvin but displays min/max/avg values in °C.

It should either report temperatures values in Kelvin either report Temperature unit as °C.

When converting with gdal_translate to an AAIGrid format file, values are in °C. In the original file, values are clearly Kelvin.

Change History (5)

comment:1 Changed 7 years ago by warmerdam

Keywords: grib added

Can you supply and some evidence to indicate that the original data is in Kelvin?

I assume this is an issue with the degrib library doing units transformation, but it might also be a specific metadata issue with a file or something. I can't event think of investigating till I have more detail.

comment:2 Changed 7 years ago by warmerdam

I'm still waiting on detail to pursue this further...

comment:3 Changed 3 years ago by serrer

Hi Frank,

I'm experiencing the same problem as creator of this ticket.

Environment Canada publishes their weather forecast data in GRIB2 format at http://

A temperature file will be named something like CMC_reg_TMP_ISBL_1000_ps10km_2014040100_P012.grib2

The values in the file are in Kelvin and GDAL reports units as K but the values appear to have been converted to deg C when one loads the file.

I'm loading the rasters with my own software via the following code snippet. GDAL version 1.9.2

GDALDataset *m_GDALDataSet = (GDALDataset *)GDALOpen(fs.GetFullSpec(), GA_ReadOnly);
GDALRasterBand *pRaster = m_GDALDataSet->GetRasterBand(1);
CPLErr err = pRaster->RasterIO(GF_Read, 0, 0, xCount, yCount, v,
            xCount, yCount, GDT_Float64, 0, 0);

However QGIS 2.2.0 displays the same symptoms.

I've corresponded with the modellers and data experts at CMC and they assure me that the data in the file is in units "deg K". See the email below...

Dear M. Serrer,

Your question was relayed to me. We investigated and we confirm that the GRIB2 files appears to be fine and there are no errors regarding temperature values and units. We suspect the problem being with the software you are using. At least QGIS and gdal_translate both use the GDAL library to read GRIB2 content. Maybe there's an issue with the GDAL GRIB2 driver?

On our end, the file appears to be properly generated.
wgrib2  -V CMC_reg_TMP_TGL_2_ps10km_2014032800_P006.grib2

1:0:vt=2014032806:2 m above ground:6 hour fcst:TMP Temperature [K]:
        polar stereographic grid: (935 x 824) input WE:SN output WE:SN res 8
        North pole lat1 18.145030 lon1 217.107456 latD 60.000000 lonV 249.000000 dx 10000.000000 m dy 10000.000000 m

Hope this helps,

Alexandre Leroux, M.Sc., ing.
National coordinator, Open Data Access (I) /
Coordonnateur national, Accès aux données ouvertes (I)
Data, Performance and Standards Section /
Section des Données, performance et standards
Environment Canada / Environnement Canada - (514) 421-5024

Martin Serrer Bldg. M-32, 1200 Montreal Road Ocean, Coastal and River Engineering National Research Council Ottawa, Ontario, Canada, K1A-0R6 (Map) Martin.Serrer@… (613) 993-9442 (voice) (613) 952-7679 (fax)

comment:4 Changed 3 years ago by Even Rouault

Milestone: 1.10.2
Resolution: fixed
Status: newclosed

trunk r27116, branches/1.10 r27117 "GRIB: display temperature unit as deg Celcius in metadata (#3606)"

Note that in GDAL 1.9 and above, you can have prevent the conversion to Celcius by setting GRIB_NORMALIZE_UNITS to NO as documented in

comment:5 Changed 3 years ago by serrer

I found GRIB_NORMALIZE_UNITS in the source code just after adding my comment here. Thanks... Martin

Note: See TracTickets for help on using tickets.