[gdal-dev] GRIB2 file extent not matchi GRIB2 metadata (grib_dump)

Rousseau Lambert,Louis-Philippe (ECCC) Louis-Philippe.RousseauLambert at ec.gc.ca
Thu Sep 28 12:31:20 PDT 2023


Hi,

I am facing an issue with GRIB2 data, and the extent reported by a gdal_info command. Here is a sample data to test: https://drive.google.com/file/d/1URvQs2qHXgRkq3YfC7ZR8VGYK3SKXB59/view?usp=drive_link

Here is what I am testing with:

  *   Ubuntu 20.04.6 LTS
  *   GDAL 3.5.2, released 2022/09/02
  *   PROJ Rel. 8.2.0, November 1st, 2021

So, using grib_dump, I see the longitude of the file should be from 0 to 360 degress:

grib_dump out.grib2 | grep shapeOfTheEarth -A 12
  shapeOfTheEarth = 6;
  Ni = 2400;
  Nj = 1201;
  iScansNegatively = 0;
  jScansPositively = 1;
  jPointsAreConsecutive = 0;
  alternativeRowScanning = 0;
  latitudeOfFirstGridPointInDegrees = -90;
  longitudeOfFirstGridPointInDegrees = 0;
  latitudeOfLastGridPointInDegrees = 90;
  longitudeOfLastGridPointInDegrees = 360;
  iDirectionIncrementInDegrees = 0.15;
  jDirectionIncrementInDegrees = 0.15;

But using gdal_info I see the extent as:

gdal_info -proj4 out.grib2 | grep PROJ -A 9
PROJ.4 string is:
'+proj=longlat +R=6371229 +no_defs'
Origin = (-0.075031263026261,90.075000000000003)
Pixel Size = (0.150062526052522,-0.150000000000000)
Corner Coordinates:
Upper Left  (  -0.0750313,  90.0750000) (  0d 4'30.11"W, 90d 4'30.00"N)
Lower Left  (  -0.0750313, -90.0750000) (  0d 4'30.11"W, 90d 4'30.00"S)
Upper Right (     360.075,      90.075) (360d 4'30.11"E, 90d 4'30.00"N)
Lower Right (     360.075,     -90.075) (360d 4'30.11"E, 90d 4'30.00"S)
Center      ( 180.0000000,   0.0000000) (180d 0' 0.00"E,  0d 0' 0.01"N)

I would expect the gdal_info extent to be also from 0 to 360 degrees (2400 pixels * 0.15 = 360). From reading various source, I see the issue is potentially that the GRIB2 files define the extent using the center of the pixel while gdal assumes it is the top left corner.

My question: Is there a way to change this behavior in gdal, or this expected, or a bug ?

Thanks

LP
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/gdal-dev/attachments/20230928/9ce83826/attachment.htm>


More information about the gdal-dev mailing list