ACCESS-Cloud-Based-InSAR / dem-stitcher

Download and merge DEM tiles
Apache License 2.0
43 stars 15 forks source link

Removal of `2021` from AWS Glo Registry #48

Closed cmarshak closed 1 year ago

cmarshak commented 1 year ago

The bug

The example on the github homepage does not work due to removal of 2021 prefix in glo-30 aws bucket.

To Reproduce

bounds = [-119.085, 33.402, -118.984, 35.435]
X, p = stitch_dem(bounds,
                  dem_name='glo_30',
                  dst_ellipsoidal_height=False,
                  dst_area_or_point='Point')
---------------------------------------------------------------------------
CPLE_HttpResponseError                    Traceback (most recent call last)
File rasterio/_base.pyx:261, in rasterio._base.DatasetBase.__init__()

File rasterio/_shim.pyx:78, in rasterio._shim.open_dataset()

File rasterio/_err.pyx:216, in rasterio._err.exc_wrap_pointer()

CPLE_HttpResponseError: HTTP response code: 404

During handling of the above exception, another exception occurred:

RasterioIOError                           Traceback (most recent call last)
Input In [22], in <cell line: 2>()
      1 bounds = [-119.085, 33.402, -118.984, 35.435]
----> 2 X, p = stitch_dem(bounds,
      3                   dem_name='glo_30',
      4                   dst_ellipsoidal_height=False,
      5                   dst_area_or_point='Point')

File ~/opt/anaconda3/envs/dem-stitcher/lib/python3.9/site-packages/dem_stitcher/stitcher.py:304, in stitch_dem(bounds, dem_name, dst_ellipsoidal_height, dst_area_or_point, dst_resolution, n_threads_reproj, n_threads_downloading, driver, fill_in_glo_30)
    302     return RASTER_READERS[dem_name](url)
    303 with ThreadPoolExecutor(max_workers=n_threads_downloading) as executor:
--> 304     results = list(tqdm(executor.map(reader, urls),
    305                         total=len(urls),
    306                         desc=f'Reading {dem_name} Datasets'))
    308 # If datasets are non-existent, returns None
    309 datasets = list(filter(lambda x: x is not None, results))

File ~/opt/anaconda3/envs/dem-stitcher/lib/python3.9/site-packages/tqdm/std.py:1195, in tqdm.__iter__(self)
   1192 time = self._time
   1194 try:
-> 1195     for obj in iterable:
   1196         yield obj
   1197         # Update and possibly print the progressbar.
   1198         # Note: does not call self.update(1) for speed optimisation.

File ~/opt/anaconda3/envs/dem-stitcher/lib/python3.9/concurrent/futures/_base.py:609, in Executor.map.<locals>.result_iterator()
    606 while fs:
    607     # Careful not to keep a reference to the popped future
    608     if timeout is None:
--> 609         yield fs.pop().result()
    610     else:
    611         yield fs.pop().result(end_time - time.monotonic())

File ~/opt/anaconda3/envs/dem-stitcher/lib/python3.9/concurrent/futures/_base.py:446, in Future.result(self, timeout)
    444     raise CancelledError()
    445 elif self._state == FINISHED:
--> 446     return self.__get_result()
    447 else:
    448     raise TimeoutError()

File ~/opt/anaconda3/envs/dem-stitcher/lib/python3.9/concurrent/futures/_base.py:391, in Future.__get_result(self)
    389 if self._exception:
    390     try:
--> 391         raise self._exception
    392     finally:
    393         # Break a reference cycle with the exception in self._exception
    394         self = None

File ~/opt/anaconda3/envs/dem-stitcher/lib/python3.9/concurrent/futures/thread.py:58, in _WorkItem.run(self)
     55     return
     57 try:
---> 58     result = self.fn(*self.args, **self.kwargs)
     59 except BaseException as exc:
     60     self.future.set_exception(exc)

File ~/opt/anaconda3/envs/dem-stitcher/lib/python3.9/site-packages/dem_stitcher/stitcher.py:302, in stitch_dem.<locals>.reader(url)
    301 def reader(url):
--> 302     return RASTER_READERS[dem_name](url)

File ~/opt/anaconda3/envs/dem-stitcher/lib/python3.9/site-packages/dem_stitcher/dem_readers.py:12, in read_dem(dem_path)
     11 def read_dem(dem_path: str) -> rasterio.DatasetReader:
---> 12     ds = rasterio.open(dem_path)
     13     return ds

File ~/opt/anaconda3/envs/dem-stitcher/lib/python3.9/site-packages/rasterio/env.py:437, in ensure_env_with_credentials.<locals>.wrapper(*args, **kwds)
    434     session = DummySession()
    436 with env_ctor(session=session):
--> 437     return f(*args, **kwds)

File ~/opt/anaconda3/envs/dem-stitcher/lib/python3.9/site-packages/rasterio/__init__.py:220, in open(fp, mode, driver, width, height, count, crs, transform, dtype, nodata, sharing, **kwargs)
    216 # Create dataset instances and pass the given env, which will
    217 # be taken over by the dataset's context manager if it is not
    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)(
    223         path, mode, driver=driver, sharing=sharing, **kwargs
    224     )

File rasterio/_base.pyx:263, in rasterio._base.DatasetBase.__init__()

RasterioIOError: HTTP response code: 404
jhkennedy commented 1 year ago

Looks like they dropped both the 2019 and 2021 prefixes, and only have the top-level tile directories now.