[gdal-dev] filter out wanted messages in a grib2 file

Zhan Zhang - NOAA Affiliate zhan.j.zhang at noaa.gov
Wed Mar 20 14:22:11 PDT 2019


Thanks, Even! Can gdalinfo also get all the bands info needed as GDALGetRasterCount() + GDALGetRasterBand() + GDALGetMetadata() + GDALGetDescription() ) work together?

> On Mar 19, 2019, at 12:44 PM, Even Rouault <even.rouault at spatialys.com> wrote:
> 
>> On dimanche 10 mars 2019 21:19:30 CET Zhan Zhang - NOAA Affiliate wrote:
>> I have a grib2 file which contains many messages, and those messages define
>> different products on different surfaces (like z axis). For
>> instance, some messages defines "soil temperature"(product name) on a
>> surface called "depth below land surface" (surface name); and other
>> messages define "geopotential height" (product name) on a "pressure
>> surface" (surface name); etc. May I ask how I can filter out all those
>> messages that defines "soil temperature"(product name) on a surface called
>> "depth below land surface" (surface name)? Is there some grib2 tools
>> provided in gdal APIs that I can use? Thanks!
> 
> Zhan,
> 
> Multiple GRIB messages in a single file are seen by GDAL as a multi-band 
> dataset.
> So you need to iterate over the bands ( GDALGetRasterCount() + 
> GDALGetRasterBand() for the C API ) and fetch its metadata ( GDALGetMetadata() 
> ) an description ( GDALGetDescription() ) to see if the band is of interest 
> for you.
> 
> The output of gdalinfo should help you understanding this
> 
> If using the Python API, you may also analyze the result of
> gdal.Info('my.grb2', format = 'json')
> which is a Python dictionary, to retrieve the band you are interested in.
> 
> Best regards,
> 
> Even
> 
> -- 
> Spatialys - Geospatial professional services
> http://www.spatialys.com


More information about the gdal-dev mailing list