You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
GRIB: "Error while packing" when writing small rasters with nodata #15428
Writing a small raster to GRIB2 fails with ERROR 1: Error while packing when the raster has a nodata value. We noticed it when cutting small subsets out of a bigger GRIB2 file. Bigger subsets of the same data write fine, only the small ones fail (around 10x10 pixels or less in our tests). This was first identified when trying to use rasterio to write a a subset of a GRIB file in a Python-based backend. Replicated below purely using GDAL.
As far as I can see the spec doesn't set a minimum grid size for templates 5.2/5.3. Small files like this are pretty normal for us since we serve GRIB2 subsets from an OGC API - Coverages endpoint where a user asking for a small bbox on a 1-degree global model (Canadian Seasonal and Interannual Prediction System [CanSIPS]) gets back a grid of only a few pixels. The idea here being that a user may subset the source data only on a specific area of interest and receive it in its native format. In this particular example, due to the rather coarse resolution of the model, sometimes those subset requests can return rather small outputs.
Activity
dbaston commentedon Oct 22, 2026
pytest reproducer:
Failure appears to propagate outward from
gdal/frmts/grib/degrib/g2clib/reduce.c
Line 279 in 0e24e02
Upstream version of that file is
https://github.com/NOAA-EMC/NCEPLIBS-g2c/blob/6542c47cef1eb177c90400eacbc0e82ab2d79520/src/reduce.c
but nothing in git history suggests substantive changes.
jratike80 commentedon Oct 22, 2026
Do you know it the GRIB format supports complex packing of so small files https://www.nco.ncep.noaa.gov/pmb/docs/grib2/grib2_doc/grib2_temp5-2.shtml and can the DeGRIB library handle them?
Are 10x10 sized GRIB2 files common in some context?
Dukestep commentedon Oct 22, 2026
As far as I can see the spec doesn't set a minimum grid size for templates 5.2/5.3. Small files like this are pretty normal for us since we serve GRIB2 subsets from an OGC API - Coverages endpoint where a user asking for a small bbox on a 1-degree global model (Canadian Seasonal and Interannual Prediction System [CanSIPS]) gets back a grid of only a few pixels. The idea here being that a user may subset the source data only on a specific area of interest and receive it in its native format. In this particular example, due to the rather coarse resolution of the model, sometimes those subset requests can return rather small outputs.
jratike80 commentedon Oct 22, 2026
This talks about packing and nodata, could there be something interesting https://github.com/OSGeo/gdal/pull/1063/changes?