I am trying to read this .grib2 file using gdal. Here's the code I use in Python:
from osgeo import gdal from osgeo.gdalconst import GA_ReadOnlyfname = 'ten_meter_20150816_00z_01.grib'dataset = gdal.Open(fname, GA_ReadOnly)band_u_velocity = dataset.GetRasterBand(1)wind_u_velocity = band_u.ReadAsArray(0, 0)I get a 1025x1473 array as expected, but all of the values are 9999. I am pretty sure the values are not all NA since I was able to make meaningful ASCII file out of the file using NOAA Weather and Climate Toolkit. Everything else is fine such as number of rows, columns, metadata, etc. I also tried using ReadRaster , ReadRaster1 and ReadBlock instead of ReadAsArray with no luck. Does anybody know what am I missing?
PS: If gdal does not work, I can try gribapi package and follow this answer, but I thought there must be a easy fix to make it work with gdal.
أكثر...
from osgeo import gdal from osgeo.gdalconst import GA_ReadOnlyfname = 'ten_meter_20150816_00z_01.grib'dataset = gdal.Open(fname, GA_ReadOnly)band_u_velocity = dataset.GetRasterBand(1)wind_u_velocity = band_u.ReadAsArray(0, 0)I get a 1025x1473 array as expected, but all of the values are 9999. I am pretty sure the values are not all NA since I was able to make meaningful ASCII file out of the file using NOAA Weather and Climate Toolkit. Everything else is fine such as number of rows, columns, metadata, etc. I also tried using ReadRaster , ReadRaster1 and ReadBlock instead of ReadAsArray with no luck. Does anybody know what am I missing?
PS: If gdal does not work, I can try gribapi package and follow this answer, but I thought there must be a easy fix to make it work with gdal.
أكثر...