0
grbs = pygrib.open(
   'https://www.ncei.noaa.gov/data/north-american-mesoscale-model/access/historical/forecast/202001/20200101/nam_218_20200101_0600_024.grb2')
grb = grbs.read(1)[0]

This is what I am trying to do, but it gives me the following error enter image description here

The link has no issue, since i can use that link and download the file in the local machine, and use pygrib.open to read file from local machine, But now I am having trouble to read file directly from the link. I read through pygrib documentation, it seems like they did not provide a way to do that. Is there any way can read grib file drectly from link?

1 Answer 1

1

You can use GDAL's Network Based File Systems. You simply have to add the /vsicurl/ prefix to the URL. Then you can access the data and all their properties.

For example:

from osgeo import gdal

ds = gdal.Open('/vsicurl/https://www.ncei.noaa.gov/data/north-american-mesoscale-model/access/historical/forecast/202001/20200101/nam_218_20200101_0600_024.grb2')
data = ds.ReadAsArray()

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.