<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic How does one get the metadata of each band of a grib file using rasterio? in Python Questions</title>
    <link>https://community.esri.com/t5/python-questions/how-does-one-get-the-metadata-of-each-band-of-a/m-p/1140198#M63649</link>
    <description>&lt;P&gt;Is there a way to see the metadata of each band of a grib file using&amp;nbsp;rasterio? Using&amp;nbsp;gdal&amp;nbsp;this can be accomplished by:&lt;/P&gt;&lt;PRE&gt;import gdal

path = r"D:\path\to\somewhere.grib"

ds = gdal.Open(path)  

for band in range(1, ds.RasterCount):
    print(ds.GetRasterBand(band).GetMetadata())&lt;/PRE&gt;&lt;P&gt;an example of one band's metadata from a GFS grib using the method above is as follows&lt;/P&gt;&lt;PRE&gt;{'GRIB_COMMENT': 'Temperature [C]', 'GRIB_DISCIPLINE': '0(Meteorological)', 'GRIB_ELEMENT': 'TMP', 'GRIB_FORECAST_SECONDS': '21600 sec', 'GRIB_IDS': 'CENTER=7(US-NCEP) SUBCENTER=0 MASTER_TABLE=2 LOCAL_TABLE=1 SIGNF_REF_TIME=1(Start_of_Forecast) REF_TIME=2022-02-02T06:00:00Z PROD_STATUS=0(Operational) TYPE=1(Forecast)', 'GRIB_PDS_PDTN': '0', 'GRIB_PDS_TEMPLATE_ASSEMBLED_VALUES': '0 0 2 0 96 0 0 1 6 1 0 0 255 0 0', 'GRIB_PDS_TEMPLATE_NUMBERS': '0 0 2 0 96 0 0 0 1 0 0 0 6 1 0 0 0 0 0 255 0 0 0 0 0', 'GRIB_REF_TIME': '  1643781600 sec UTC', 'GRIB_SHORT_NAME': '0-SFC', 'GRIB_UNIT': '[C]', 'GRIB_VALID_TIME': '  1643803200 sec UTC'}&lt;/PRE&gt;&lt;P&gt;I'm trying to get this same information but using&amp;nbsp;rasterio&amp;nbsp;instead. Is this possible? So far I've&lt;A href="https://www.olansigr.com" target="_self"&gt;&amp;nbsp;&lt;/A&gt;tried&lt;/P&gt;&lt;PRE&gt;import rasterio 

with rasterio.open(file) as src:
    print(src.descriptions)
    print(src.meta)
    print(src.profile)&lt;/PRE&gt;&lt;P&gt;with the closest being&amp;nbsp;src.descriptions. However, it only gave the following&lt;/P&gt;&lt;PRE&gt;('0[-] SFC="Ground or water surface"')&lt;/PRE&gt;&lt;P&gt;It seems to be only getting a piece of the metadata. Does anyone know how to get the rest?&lt;/P&gt;</description>
    <pubDate>Thu, 17 Feb 2022 10:44:30 GMT</pubDate>
    <dc:creator>HaniMalik</dc:creator>
    <dc:date>2022-02-17T10:44:30Z</dc:date>
    <item>
      <title>How does one get the metadata of each band of a grib file using rasterio?</title>
      <link>https://community.esri.com/t5/python-questions/how-does-one-get-the-metadata-of-each-band-of-a/m-p/1140198#M63649</link>
      <description>&lt;P&gt;Is there a way to see the metadata of each band of a grib file using&amp;nbsp;rasterio? Using&amp;nbsp;gdal&amp;nbsp;this can be accomplished by:&lt;/P&gt;&lt;PRE&gt;import gdal

path = r"D:\path\to\somewhere.grib"

ds = gdal.Open(path)  

for band in range(1, ds.RasterCount):
    print(ds.GetRasterBand(band).GetMetadata())&lt;/PRE&gt;&lt;P&gt;an example of one band's metadata from a GFS grib using the method above is as follows&lt;/P&gt;&lt;PRE&gt;{'GRIB_COMMENT': 'Temperature [C]', 'GRIB_DISCIPLINE': '0(Meteorological)', 'GRIB_ELEMENT': 'TMP', 'GRIB_FORECAST_SECONDS': '21600 sec', 'GRIB_IDS': 'CENTER=7(US-NCEP) SUBCENTER=0 MASTER_TABLE=2 LOCAL_TABLE=1 SIGNF_REF_TIME=1(Start_of_Forecast) REF_TIME=2022-02-02T06:00:00Z PROD_STATUS=0(Operational) TYPE=1(Forecast)', 'GRIB_PDS_PDTN': '0', 'GRIB_PDS_TEMPLATE_ASSEMBLED_VALUES': '0 0 2 0 96 0 0 1 6 1 0 0 255 0 0', 'GRIB_PDS_TEMPLATE_NUMBERS': '0 0 2 0 96 0 0 0 1 0 0 0 6 1 0 0 0 0 0 255 0 0 0 0 0', 'GRIB_REF_TIME': '  1643781600 sec UTC', 'GRIB_SHORT_NAME': '0-SFC', 'GRIB_UNIT': '[C]', 'GRIB_VALID_TIME': '  1643803200 sec UTC'}&lt;/PRE&gt;&lt;P&gt;I'm trying to get this same information but using&amp;nbsp;rasterio&amp;nbsp;instead. Is this possible? So far I've&lt;A href="https://www.olansigr.com" target="_self"&gt;&amp;nbsp;&lt;/A&gt;tried&lt;/P&gt;&lt;PRE&gt;import rasterio 

with rasterio.open(file) as src:
    print(src.descriptions)
    print(src.meta)
    print(src.profile)&lt;/PRE&gt;&lt;P&gt;with the closest being&amp;nbsp;src.descriptions. However, it only gave the following&lt;/P&gt;&lt;PRE&gt;('0[-] SFC="Ground or water surface"')&lt;/PRE&gt;&lt;P&gt;It seems to be only getting a piece of the metadata. Does anyone know how to get the rest?&lt;/P&gt;</description>
      <pubDate>Thu, 17 Feb 2022 10:44:30 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/how-does-one-get-the-metadata-of-each-band-of-a/m-p/1140198#M63649</guid>
      <dc:creator>HaniMalik</dc:creator>
      <dc:date>2022-02-17T10:44:30Z</dc:date>
    </item>
    <item>
      <title>Re: How does one get the metadata of each band of a grib file using rasterio?</title>
      <link>https://community.esri.com/t5/python-questions/how-does-one-get-the-metadata-of-each-band-of-a/m-p/1140202#M63651</link>
      <description>&lt;P data-unlink="true"&gt;rasterio isn't part of the ArcGIS suite of software, you might be better off asking on the &lt;A href="https://rasterio.groups.io/g/main" target="_self"&gt;rasterio group&lt;/A&gt; or &lt;A href="https://gis.stackexchange.com/questions/ask" target="_self"&gt;GIS StackExchange&lt;/A&gt;.&lt;/P&gt;</description>
      <pubDate>Thu, 03 Feb 2022 08:35:22 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/how-does-one-get-the-metadata-of-each-band-of-a/m-p/1140202#M63651</guid>
      <dc:creator>Luke_Pinner</dc:creator>
      <dc:date>2022-02-03T08:35:22Z</dc:date>
    </item>
  </channel>
</rss>

