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

classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

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

Zhan Zhang - NOAA Affiliate
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!     

_______________________________________________
gdal-dev mailing list
[hidden email]
https://lists.osgeo.org/mailman/listinfo/gdal-dev
Reply | Threaded
Open this post in threaded view
|

Re: filter out wanted messages in a grib2 file

Zhan Zhang - NOAA Affiliate
when I say "filter out", I mean "retrieve". 

On Sun, Mar 10, 2019 at 9:19 PM Zhan Zhang - NOAA Affiliate <[hidden email]> 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!     

_______________________________________________
gdal-dev mailing list
[hidden email]
https://lists.osgeo.org/mailman/listinfo/gdal-dev
Reply | Threaded
Open this post in threaded view
|

Re: filter out wanted messages in a grib2 file

Even Rouault-2
In reply to this post by Zhan Zhang - NOAA Affiliate
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
_______________________________________________
gdal-dev mailing list
[hidden email]
https://lists.osgeo.org/mailman/listinfo/gdal-dev
Reply | Threaded
Open this post in threaded view
|

Re: filter out wanted messages in a grib2 file

Zhan Zhang - NOAA Affiliate
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 <[hidden email]> 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
_______________________________________________
gdal-dev mailing list
[hidden email]
https://lists.osgeo.org/mailman/listinfo/gdal-dev