Skip to content

Gallery example "RGB image": Failing with error "rasterio.errors.RasterioIOError: HTTP response code: 403" #3771

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
yvonnefroehlich opened this issue Jan 16, 2025 · 1 comment · Fixed by #3781
Labels
bug Something isn't working
Milestone

Comments

@yvonnefroehlich
Copy link
Member

Description of the problem

There is currently a problem with the Gallery example RGB image. Recently building the docs started failing, please see https://readthedocs.org/projects/pygmt-dev/builds/26866465/ and https://readthedocs.org/projects/pygmt-dev/builds/26866703/:

Unexpected failing examples (1):

    ../examples/gallery/images/rgb_image.py failed leaving traceback:

    Traceback (most recent call last):
      File "/home/docs/checkouts/readthedocs.org/user_builds/pygmt-dev/checkouts/3594/examples/gallery/images/rgb_image.py", line 24, in <module>
        with rioxarray.open_rasterio(
             ~~~~~~~~~~~~~~~~~~~~~~~^
            filename="https://oin-hotosm.s3.us-east-1.amazonaws.com/64d6a49a19cb3a000147a65b/0/64d6a49a19cb3a000147a65c.tif",
            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
            overview_level=5,
            ^^^^^^^^^^^^^^^^^
        ) as img:
        ^
      File "/home/docs/checkouts/readthedocs.org/user_builds/pygmt-dev/conda/3594/lib/python3.13/site-packages/rioxarray/_io.py", line 1128, in open_rasterio
        riods = manager.acquire()
      File "/home/docs/checkouts/readthedocs.org/user_builds/pygmt-dev/conda/3594/lib/python3.13/site-packages/xarray/backends/file_manager.py", line 193, in acquire
        file, _ = self._acquire_with_cache_info(needs_lock)
                  ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^
      File "/home/docs/checkouts/readthedocs.org/user_builds/pygmt-dev/conda/3594/lib/python3.13/site-packages/xarray/backends/file_manager.py", line 217, in _acquire_with_cache_info
        file = self._opener(*self._args, **kwargs)
      File "/home/docs/checkouts/readthedocs.org/user_builds/pygmt-dev/conda/3594/lib/python3.13/site-packages/rasterio/env.py", line 463, in wrapper
        return f(*args, **kwds)
      File "/home/docs/checkouts/readthedocs.org/user_builds/pygmt-dev/conda/3594/lib/python3.13/site-packages/rasterio/__init__.py", line 356, in open
        dataset = DatasetReader(path, driver=driver, sharing=sharing, **kwargs)
      File "rasterio/_base.pyx", line 312, in rasterio._base.DatasetBase.__init__
    rasterio.errors.RasterioIOError: HTTP response code: 403

I also face this problem when running the example locally on my laptop (see error message below).

Trying to download the tif file directly via the URL in Python script (https://oin-hotosm.s3.us-east-1.amazonaws.com/64d6a49a19cb3a000147a65b/0/64d6a49a19cb3a000147a65c.tif), gives the following error

This XML file does not appear to have any style information associated with it. The document tree is shown below.
<Error>
<Code>AccessDenied</Code>
<Message>Access Denied</Message>
<RequestId>C9H0CY2Y53QW56B0</RequestId>
<HostId>OO/RzWA3IdFtauXZcXQ8UEeY3f1ixpK6DTIJxEHuaxaQfrV33+WD3mg8D9ej3NP5Uw1Bl+8hcg8FWA8mAhpSX5n5Jh0thQxhXmiQcOazL8A=</HostId>
</Error>

Minimal Complete Verifiable Example

# Gallery example "RGB image"
# https://www.pygmt.org/dev/gallery/images/rgb_image.html#sphx-glr-gallery-images-rgb-image-py

import pygmt
import rioxarray


with rioxarray.open_rasterio(
    filename="https://oin-hotosm.s3.us-east-1.amazonaws.com/64d6a49a19cb3a000147a65b/0/64d6a49a19cb3a000147a65c.tif",
    overview_level=5,
) as img:
    # Subset to area of Lāhainā in EPSG:32604 coordinates
    image = img.rio.clip_box(minx=738000, maxx=755000, miny=2300000, maxy=2318000)
    image = image.load()  # Force loading the DataArray into memory
image

# %%
fig = pygmt.Figure()
with pygmt.config(FONT_TITLE="Times-Roman"):  # Set title font to Times-Roman
    fig.grdimage(
        grid=image,
        # Use a map scale where 1 cm on the map equals 1 km on the ground
        projection="x1:100000",
        frame=[r"WSne+tL@!a¯hain@!a¯, Hawai`i on 9 Aug 2023", "af"],
    )
fig.show()

Full error message

Traceback (most recent call last):

  File C:\ProgramData\Anaconda3\envs\pygmt_env_dev_650\Lib\site-packages\xarray\backends\file_manager.py:211 in _acquire_with_cache_info
    file = self._cache[self._key]

  File C:\ProgramData\Anaconda3\envs\pygmt_env_dev_650\Lib\site-packages\xarray\backends\lru_cache.py:56 in __getitem__
    value = self._cache[key]

KeyError: [<function open at 0x000001AE65C60CC0>, ('https://oin-hotosm.s3.us-east-1.amazonaws.com/64d6a49a19cb3a000147a65b/0/64d6a49a19cb3a000147a65c.tif',), 'r', (('overview_level', 5), ('sharing', False)), '8b2830bf-030f-4bd6-885b-0f4728a7c4c6']


During handling of the above exception, another exception occurred:

Traceback (most recent call last):

  File rasterio\\_base.pyx:310 in rasterio._base.DatasetBase.__init__

  File rasterio\\_base.pyx:221 in rasterio._base.open_dataset

  File rasterio\\_err.pyx:221 in rasterio._err.exc_wrap_pointer

CPLE_HttpResponseError: HTTP response code: 403


During handling of the above exception, another exception occurred:

Traceback (most recent call last):

  File C:\ProgramData\Anaconda3\envs\pygmt_env_dev_650\Lib\site-packages\spyder_kernels\py3compat.py:356 in compat_exec
    exec(code, globals, locals)

  File c:\users\admin\c2\eigenedokumente\studium\promotion\01_github\github_map\gmt-pygmt-plotting\000_general_stuff\02_colorwheel\untitled0.py:19
    with rioxarray.open_rasterio(

  File C:\ProgramData\Anaconda3\envs\pygmt_env_dev_650\Lib\site-packages\rioxarray\_io.py:1124 in open_rasterio
    riods = manager.acquire()

  File C:\ProgramData\Anaconda3\envs\pygmt_env_dev_650\Lib\site-packages\xarray\backends\file_manager.py:193 in acquire
    file, _ = self._acquire_with_cache_info(needs_lock)

  File C:\ProgramData\Anaconda3\envs\pygmt_env_dev_650\Lib\site-packages\xarray\backends\file_manager.py:217 in _acquire_with_cache_info
    file = self._opener(*self._args, **kwargs)

  File C:\ProgramData\Anaconda3\envs\pygmt_env_dev_650\Lib\site-packages\rasterio\env.py:451 in wrapper
    return f(*args, **kwds)

  File C:\ProgramData\Anaconda3\envs\pygmt_env_dev_650\Lib\site-packages\rasterio\__init__.py:304 in open
    dataset = DatasetReader(path, driver=driver, sharing=sharing, **kwargs)

  File rasterio\\_base.pyx:312 in rasterio._base.DatasetBase.__init__

RasterioIOError: HTTP response code: 403

System information

PyGMT information:
  version: v0.14.1.dev10
System information:
  python: 3.12.3 | packaged by conda-forge | (main, Apr 15 2024, 18:20:11) [MSC v.1938 64 bit (AMD64)]
  executable: C:\ProgramData\Anaconda3\envs\pygmt_env_dev_650\python.exe
  machine: Windows-10-10.0.19045-SP0
Dependency information:
  numpy: 1.26.4
  pandas: 2.2.0rc0
  xarray: 2024.3.0
  netCDF4: 1.6.5
  packaging: 24.0
  contextily: 1.6.0
  geopandas: 0.14.3
  IPython: 8.22.2
  pyarrow: None
  rioxarray: 0.15.4
  gdal: 3.8.2
  ghostscript: 10.03.0
GMT library information:
  version: 6.5.0
  padding: 2
  share dir: C:/Program Files (x86)/gmt6/share
  plugin dir: C:/ProgramData/Anaconda3/envs/pygmt_env_dev_650/Library/bin/gmt_plugins
  library path: C:/ProgramData/Anaconda3/envs/pygmt_env_dev_650/Library/bin/gmt.dll
  cores: 4
  grid layout: rows
  image layout: 
  binary version: 6.5.0
@yvonnefroehlich yvonnefroehlich added the bug Something isn't working label Jan 16, 2025
@yvonnefroehlich yvonnefroehlich changed the title Gallery example "RGB image": Gallery example "RGB image": Failing with error "rasterio.errors.RasterioIOError: HTTP response code: 403" Jan 16, 2025
@seisman
Copy link
Member

seisman commented Jan 26, 2025

I guess we have to find another RGB image for this gallery example.

Edit: Will be fixed by #3781.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants