[gdal-dev] can't open grib2 files

Scott Sinclair scott.sinclair.za at gmail.com
Fri Jul 10 11:45:50 EDT 2009


Hi Alberto,

I'm not sure what's going on, without poking into the GDAL source code
(with which I'm really not that familiar).

I typically use the pygrib2 package to handle GRIB2 data
(http://code.google.com/p/pygrib2). Under the hood this package uses
g2clib (found at http://www.nco.ncep.noaa.gov/pmb/codes/GRIB2). The
GDAL GRIB driver uses degrib (http://www.nws.noaa.gov/mdl/degrib),
which is also based on (an older version of) g2clib.

I had noticed that the outputs from gdal_translate for the EUMETSAT
MPE data appeared binary in nature, but didn't spend much time
investigating and assumed that my viewer program was just having
trouble representing the large range of values properly (no-data
values are very different from the rainfall values).

I believe that a robust GDAL GRIB driver may be tricky to implement
properly, because the GRIB1/2 data model is more flexible than a GDAL
Raster Dataset. I would still expect the current driver to give
sensible results in this case though, perhaps someone more
knowledgeable could comment..

No problem bothering me directly, but it's usually more likely that
you'll get the best information from a larger audience. If you could
make your example files available on the web, it will probably be
useful, I haven't attached them to this mail.

Cheers,
Scott

> 2009/7/10 Alberto Pettazzi <alberto.pettazzi at meteogalicia.es>:
> Dear Scott,
>
> sorry for disturbing you once more, but I am still having problems with the
> grib files of rainfall estimates...
> I created a tif file from the grib2 file, with the command you suggested me
>
> gdal_translate -b 1 MPE_20090709_1200_M9_00.grb MPE_20090709_1200_M9_00.tif
>
> It works fine. But, when I try to open with a Geotiff viewer (for example,
> QGis or typing gdalinfo -mm) in order to look at the values, I realize that
> the image only contains 0 or 9999. The tiff should appear like the .jpg I
> attached (actually, the jpeg corresponds to the grib file I attached).
> I tried also different options, in the gdal_translate command, for example
> gdal_translate -b 1 MPE_20090709_1200_M9_00.grb MPE_20090709_1200_M9_00.tif
> -a_nodata 111 -ot Float32 -strict
> but with no success.
>
> Any idea?
>
> thank you and sorry for bothering you
>
> Alberto Pettazzi
>
>
> MeteoGalicia - Departamento de Climatología y Observación
>
> Consellería de Medio Ambiente, Territorio e Infraestruturas
>
> Rúa de Roma, 6
>
> 15707 Santiago de Compostela. A Coruña
>
>
> Teléfono: +34-881-999646
>
>
> e-mail: alberto.pettazzi at meteogalicia.es
> <mailto:alberto.pettazzi at meteogalicia.es>
>
>
>
>
> Scott Sinclair escribió:
>>
>> When you run gdalinfo on the input file you'll see that the GRIB file
>> has 3 bands. The last two are quality flags at a different spatial
>> resolution to the rainfall estimates (it seems that's what causes the
>> GRIB driver to choke). See
>>
>> http://www.eumetsat.int/groups/ops/documents/document/pdf_metprod_mpe_quality_info.pdf
>>
>> Using the -b flag to gdal_translate works for me:
>>
>> $ gdalinfo --version
>> GDAL 1.6.1, released 2009/05/11
>> $ gdal_translate -b 1 MPE_20090629_0900_M9_00.grb
>> MPE_20090629_0900_M9_00.tif
>> $ gdalinfo MPE_20090629_0900_M9_00.tif
>> Driver: GTiff/GeoTIFF
>> Files: MPE_20090629_0900_M9_00.tif
>> Size is 3712, 3712
>> Coordinate System is:
>> LOCAL_CS["unnamed",
>>    UNIT["metre",1,
>>        AUTHORITY["EPSG","9001"]]]
>> Origin = (-5568748.275999999605119,5568748.275999999605119)
>> Pixel Size = (3000.403165948275728,-3000.403165948275728)
>> Metadata:
>>  AREA_OR_POINT=Area
>> Image Structure Metadata:
>>  INTERLEAVE=BAND
>> Corner Coordinates:
>> Upper Left  (-5568748.276, 5568748.276)
>> Lower Left  (-5568748.276,-5568748.276)
>> Upper Right ( 5568748.276, 5568748.276)
>> Lower Right ( 5568748.276,-5568748.276)
>> Center      (   0.0000000,  -0.0000000)
>> Band 1 Block=3712x1 Type=Float64, ColorInterp=Gray
>>  Metadata:
>>    GRIB_UNIT=[kg/(m^2*s)]
>>    GRIB_COMMENT=Instantaneous rain rate [kg/(m^2*s)]
>>    GRIB_SHORT_NAME=0 undefined
>>    GRIB_REF_TIME=1246266000 sec UTC
>>    GRIB_VALID_TIME=1246266000 sec UTC
>>    GRIB_FORECAST_SECONDS=0 sec
>>    GRIB_PDS_PDTN=30
>>    GRIB_PDS_TEMPLATE_NUMBERS=1 1 8 7 1 1 77 0 56 207 255 255 255 255 255
>>
>> Cheers,
>> Scott
>>
>>
>


More information about the gdal-dev mailing list