I’ve already the URL but seems that something goes wrong at GDAL level. Here below what I’ve been testing and the error:
rxr.open_rasterio('https://modissa.blob.core.windows.net/modis-006/MOD09Q1/22/07/2021289/MOD09Q1.A2021289.h22v07.006.2021299111058.hdf', chunks= 'auto')
return an error like this:
---------------------------------------------------------------------------
KeyError Traceback (most recent call last)
/srv/conda/envs/notebook/lib/python3.8/site-packages/xarray/backends/file_manager.py in _acquire_with_cache_info(self, needs_lock)
198 try:
--> 199 file = self._cache[self._key]
200 except KeyError:
/srv/conda/envs/notebook/lib/python3.8/site-packages/xarray/backends/lru_cache.py in __getitem__(self, key)
52 with self._lock:
---> 53 value = self._cache[key]
54 self._cache.move_to_end(key)
KeyError: [<function open at 0x7fe52d837700>, ('https://modissa.blob.core.windows.net/modis-006/MOD09Q1/22/07/2021289/MOD09Q1.A2021289.h22v07.006.2021299111058.hdf',), 'r', (('sharing', False),)]
During handling of the above exception, another exception occurred:
CPLE_OpenFailedError Traceback (most recent call last)
rasterio/_base.pyx in rasterio._base.DatasetBase.__init__()
rasterio/_shim.pyx in rasterio._shim.open_dataset()
rasterio/_err.pyx in rasterio._err.exc_wrap_pointer()
CPLE_OpenFailedError: '/vsicurl/https://modissa.blob.core.windows.net/modis-006/MOD09Q1/22/07/2021289/MOD09Q1.A2021289.h22v07.006.2021299111058.hdf' not recognized as a supported file format.
During handling of the above exception, another exception occurred:
RasterioIOError Traceback (most recent call last)
/tmp/ipykernel_539/3845122745.py in <module>
----> 1 rxr.open_rasterio('https://modissa.blob.core.windows.net/modis-006/MOD09Q1/22/07/2021289/MOD09Q1.A2021289.h22v07.006.2021299111058.hdf' class="ansi-blue-fg">, chunks= 'auto')
/srv/conda/envs/notebook/lib/python3.8/site-packages/rioxarray/_io.py in open_rasterio(filename, parse_coordinates, chunks, cache, lock, masked, mask_and_scale, variable, group, default_name, decode_times, decode_timedelta, **open_kwargs)
831 else:
832 manager = URIManager(rasterio.open, filename, mode="r", kwargs=open_kwargs)
--> 833 riods = manager.acquire()
834 captured_warnings = rio_warnings.copy()
835
/srv/conda/envs/notebook/lib/python3.8/site-packages/xarray/backends/file_manager.py in acquire(self, needs_lock)
179 An open file object, as returned by ``opener(*args, **kwargs)``.
180 """
--> 181 file, _ = self._acquire_with_cache_info(needs_lock)
182 return file
183
/srv/conda/envs/notebook/lib/python3.8/site-packages/xarray/backends/file_manager.py in _acquire_with_cache_info(self, needs_lock)
203 kwargs = kwargs.copy()
204 kwargs["mode"] = self._mode
--> 205 file = self._opener(*self._args, **kwargs)
206 if self._mode == "w":
207 # ensure file doesn't get overriden when opened again
/srv/conda/envs/notebook/lib/python3.8/site-packages/rasterio/env.py in wrapper(*args, **kwds)
435
436 with env_ctor(session=session):
--> 437 return f(*args, **kwds)
438
439 return wrapper
/srv/conda/envs/notebook/lib/python3.8/site-packages/rasterio/__init__.py in open(fp, mode, driver, width, height, count, crs, transform, dtype, nodata, sharing, **kwargs)
218 # None.
219 if mode == 'r':
--> 220 s = DatasetReader(path, driver=driver, sharing=sharing, **kwargs)
221 elif mode == "r+":
222 s = get_writer_for_path(path, driver=driver)(
rasterio/_base.pyx in rasterio._base.DatasetBase.__init__()
RasterioIOError: '/vsicurl/https://modissa.blob.core.windows.net/modis-006/MOD09Q1/22/07/2021289/MOD09Q1.A2021289.h22v07.006.2021299111058.hdf' not recognized as a supported file format.
by the way, HDF is supported.
Configuration is really scarce on rasterio.env module and mostly focus on AWS but I’ve test as well this approach with the same result.
import rasterio
with rasterio.env.Env(AZURE_STORAGE_ACCOUNT='modissa', AZURE_STORAGE_SAS_TOKEN='sv=2019-12-12&si=modis-ro&sr=c&sig=jauBgV7FNXyhbjO60XSMr6AnFFd5sl%2BwXsNazkOOFjs%3D'):
ds_250 = rxr.open_rasterio('https://modissa.blob.core.windows.net/modis-006/MOD09Q1/22/07/2021289/MOD09Q1.A2021289.h22v07.006.2021299111058.hdf', chunks= 'auto')
At the end I’ve been testing at the real base through GDAL following GDAL Virtual File Systems documentation (not pretty sure about the account name but I didn’t had any other idea) but it fails as well with a timeout:
export $AZURE_STORAGE_ACCOUNT='modissa'
export AZURE_STORAGE_SAS_TOKEN='sv=2019-12-12&si=modis-ro&sr=c&sig=jauBgV7FNXyhbjO60XSMr6AnFFd5sl%2BwXsNazkOOFjs%3D'
gdalinfo /vsiaz/https://modissa.blob.core.windows.net/modis-006/MOD09Q1/22/07/2021289/MOD09Q1.A2021289.h22v07.006.2021299111058.hdf