[mapserver-users] GRIB files

Frank Warmerdam warmerdam at pobox.com
Tue May 12 14:33:20 EDT 2009


Jose Roberto M. Garcia, MSc wrote:
> Hi all,
> 
> I'm trying to work with GRIB files in MapServer but it's not working. I 
> know that when we work with images we need to classify the output using 
> "[pixel]" as a CLASSITEM and make classes for each value but how is it 
> for GRIB files? I have several levels an variables in it. How do I 
> classify them? Does anybody explain me?

Roberto,

It would be helpful if you could make a GRIB file typical of what you want
to use available for download, so we could speak in the context of that file.

Grib files often include a number of variables.  These variables typically
get unrolled as bands.  If the variable is 3D (ie. has a time or elevation
dimension) then it may be unrolled as multiple bands from a GDAL point of
view.  One sample GRIB file I happen to have ends up with 40 bands, two of
which look like this when reported by gdalinfo:

Band 1 Block=360x1 Type=Float64, ColorInterp=Undefined
   Description = 5[m] DBSL (Depth below sea level)
   Metadata:
     GRIB_UNIT=[K]
     GRIB_COMMENT=Potential temperature [K]
     GRIB_ELEMENT=POT
     GRIB_SHORT_NAME=5-DBSL
     GRIB_REF_TIME=  1130716800 sec UTC
     GRIB_VALID_TIME=  1133308800 sec UTC
     GRIB_FORECAST_SECONDS=2592000 sec
Band 2 Block=360x1 Type=Float64, ColorInterp=Undefined
   Description = 15[m] DBSL (Depth below sea level)
   Metadata:
     GRIB_UNIT=[K]
     GRIB_COMMENT=Potential temperature [K]
     GRIB_ELEMENT=POT
     GRIB_SHORT_NAME=15-DBSL
     GRIB_REF_TIME=  1130716800 sec UTC
     GRIB_VALID_TIME=  1133308800 sec UTC
     GRIB_FORECAST_SECONDS=2592000 sec

As you can see these are temperature values for different depths
below sea level.

Once you know what band(s) you want to work with in MapServer you can
select them using the BANDS= processing directive.

   eg.
    PROCESSING "BANDS=2"

would select the 2nd band for display.

Then you can use classification as you describe.  In this case the
pixel values are presumably floating point temperatures measured in
degrees Kelvin though I'm not that familiar with the product.  Pay
particular attention to the online mapserver docs on classifying
non-8bit data as there are some caveats in this regard. I hope this
gets you going.

I would suggest:
   o inspecting your file(s) with gdalinfo, reviewing the metadata.
   o Translate individual bands into GeoTIFF files and visualize
     and inspect the results with desktop software like QGIS or OpenEV.

Then move to mapserver once you are more comfortable you know how
the data is being represented through GDAL.

Best regards,
-- 
---------------------------------------+--------------------------------------
I set the clouds in motion - turn up   | Frank Warmerdam, warmerdam at pobox.com
light and sound - activate the windows | http://pobox.com/~warmerdam
and watch the world go round - Rush    | Geospatial Programmer for Rent



More information about the mapserver-users mailing list