Skip to content

load_earth_relief fails with gebco 03s/01s datasets #4177

Closed

Description

@FilLTP89

Description of the problem

I compile gmt from source, within a docker file:

git clone https://github.com/GenericMappingTools/gmt.git
cd gmt && mkdir build && cd build &&
cmake -G Ninja .. && cmake --build . --target install

and install pygmt with pip install pygmt[all]

I cannot download earth relief from gebco (resolution 03s). I defined a local cache directory to be able to run on docker:

ENV GMT_USERDIR=/gmt_cache

But my feeling is that GEBCO Data are not available on the standard gmt servers.

Full script that generated the error

topography=pygmt.datasets.load_earth_relief(region=(20.2,20.9,38.0,38.54),data_source="gebc\
o",use_srtm=False,resolution="03s")

Full error message

Traceback (most recent call last):
  File "<python-input-2>", line 1, in <module>
    topography=pygmt.datasets.load_earth_relief(region=(20.2,20.9,38.0,38.54),data_source="gebco",use_srtm=False,resolution="03s")
  File "/app/easyrisk/lib/python3.13/site-packages/pygmt/datasets/earth_relief.py", line 180, in load_earth_relief
    grid = _load_remote_dataset(
        name=name,
    ...<3 lines>...
        registration=registration,
    )
  File "/app/easyrisk/lib/python3.13/site-packages/pygmt/datasets/load_remote_dataset.py", line 582, in _load_remote_dataset
    grid = xr.load_dataarray(
        fname, engine="gmt", raster_kind=dataset.kind, region=region
    )
  File "/app/easyrisk/lib/python3.13/site-packages/xarray/backends/api.py", line 190, in load_dataarray
    with open_dataarray(filename_or_obj, **kwargs) as da:
         ~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/app/easyrisk/lib/python3.13/site-packages/xarray/backends/api.py", line 803, in open_dataarray
    dataset = open_dataset(
        filename_or_obj,
    ...<16 lines>...
        **kwargs,
    )
  File "/app/easyrisk/lib/python3.13/site-packages/xarray/backends/api.py", line 596, in open_dataset
    backend_ds = backend.open_dataset(
        filename_or_obj,
    ...<2 lines>...
        **kwargs,
    )
  File "/app/easyrisk/lib/python3.13/site-packages/pygmt/helpers/decorators.py", line 742, in new_module
    return module_func(*bound.args, **bound.kwargs)
  File "/app/easyrisk/lib/python3.13/site-packages/pygmt/xarray/backend.py", line 149, in open_dataset
    source: str | list = which(fname=filename_or_obj, verbose="quiet")
                         ~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/app/easyrisk/lib/python3.13/site-packages/pygmt/helpers/decorators.py", line 576, in new_module
    return module_func(*args, **kwargs)
  File "/app/easyrisk/lib/python3.13/site-packages/pygmt/src/which.py", line 88, in which
    raise FileNotFoundError(msg)
FileNotFoundError: File(s) '@earth_gebco_03s_g' not found.```

**Actual outcome**


**Expected outcome**

I tried to downgrade to v 6.5.0 and i have the same problem.

**System information**
Pulling `debian:sid` from dockerhub.

* Operating system:
* GMT version (`gmt --version`): I tried the latest (v 6.7.0) and v. 6.5.0

Activity

  1. added
    bug
    on Oct 25, 2025
  2. Esteban82 commented on Oct 25, 2025

    @Esteban82
    Member

    Hi @FilLTP89. I try this command and it worked:

    gmt grdimage @earth_gebco_03 -RUY -png test -B

    I don't think it is a bug.

    Feel free to check the pygmt tutorial or to make a question in the GMT forum.

  3. joa-quim commented on Oct 26, 2025

    @joa-quim
    Member
  4. FilLTP89 commented on Oct 27, 2025

    @FilLTP89
    Author

    @Esteban82 I tried the exact same command and obtained:

    grdimage [NOTICE]: Downloading dcw-countries.txt for the first time - be patient
    grdimage [NOTICE]: Downloading dcw-states.txt for the first time - be patient
    grdimage [NOTICE]: Downloading dcw-collections.txt for the first time - be patient
    grdimage [NOTICE]: Downloading dcw-gmt.nc for the first time - be patient
    grdimage [ERROR]: Libcurl Error: HTTP response code said error
    grdimage [ERROR]: Probably means @earth_gebco_03 does not exist on the remote server
    grdimage [ERROR]: Unable to obtain remote file @earth_gebco_03

    How is it this not a bug @joa-quim ??

  5. anbj commented on Oct 27, 2025

    @anbj

    I think @Esteban82 is missing the resolution at the end.
    Add _03s.

    $ gmt grdimage @earth_gebco_03s -RUY -png test -B
    
  6. joa-quim commented on Oct 27, 2025

    @joa-quim
    Member

    How is it this not a bug @joa-quim ??

    Probably means @earth_gebco_03 does not exist on the remote server.

    A non-existing file is not a bug. But @anbj already gave you the answer.

  7. Esteban82 commented on Oct 27, 2025

    @Esteban82
    Member

    @Esteban82 I tried the exact same command and obtained:

    Yes, sorry. I forgot the s.

  8. github-actions commented on Oct 28, 2025

    @github-actions
    Contributor

    👋 Thanks for opening your first issue here!

    Please make sure you filled out the template with as much detail as possible. You might also want to take a look at our contributing guidelines and code of conduct.

  9. added this to the 0.18.0 milestone on Oct 28, 2025
  10. seisman commented on Oct 28, 2025

    @seisman
    Member

    As explained in the GMT forum https://forum.generic-mapping-tools.org/t/gebco-earth-relief-data-file-not-found/6271/2, this is actually a PyGMT bug, so I've transfered the issue to the PyGMT repository:

    The error you're having is due to the following reasons:

    1. The GMT remote server doesn't provide the 03s and 01s resolution earth_gebco datasets. When you request the dataset @earth_gebco_03s_g, GMT downloads @earth_relief_03s_g instead. This can be verified if you run the following command and check the debugging messages:
    $ gmt grdimage @earth_gebco_03s -RUY -png test -B -Vd
    
    1. PyGMT doesn't know that earth_gebco_03s/earth_gebco_01s are directed to earth_relief_03s/earth_relief_01s, so it still tries to find the earth_gebco_03s files. That's why you see the FileNotFoundError.

    So, I think it's a PyGMT bug.

    For your case, you can use data_source="igpp" as a workaround.

  11. changed the title [-]load_earth_relief with gebco data v.6.7.0[/-] [+]load_earth_relief fails with gebco 03s/01s datasets[/+] on Oct 28, 2025
  12. seisman commented on Nov 8, 2025

    @seisman
    Member

    As mentioned above, the GMT remote server doesn't provide 03s and 01s resolutions for earth_gebco/earth_gebcosi/earth_synbath datasets. When users request a dataset like @earth_gebco_03s, GMT uses @earth_relief_03s instead, but PyGMT doesn't know it, and tries to find the path to @earth_gebco_03s tiles and fails.

    We have two solutions when users request 03s/01s gebco/gebcosi/synbath datasets:

    1. Raise an error and explain that it's only available when data_source="igpp".
    2. Internally change the dataset prefix from earth_relief

    I prefer option 1 since it's simpler and users know exactly what's happening.

  13. FilLTP89 commented on Dec 5, 2025

    @FilLTP89
    Author

    I can confirm that load_earth_relief works for GEBCO data at 03s and 01s, until version 6.5. The main difference between that version and the latest is the following lines:

    pygmt<=6.5

    fname = f"@{prefix}_{resolution}_{reg}"
        kind = "image" if name in {"earth_day", "earth_night"} else "grid"
        kwdict = {"R": region, "T": {"grid": "g", "image": "i"}[kind]}
        with Session() as lib:
            with lib.virtualfile_out(kind=kind) as voutgrd:
                lib.call_module(
                    module="read",
                    args=[fname, voutgrd, *build_arg_list(kwdict)],
                )
                grid = lib.virtualfile_to_raster(kind=kind, outgrid=None, vfname=voutgrd)
    
        # Full path to the grid if not tiled grids.
        source = which(fname, download="a") if not resinfo.tiled else None
        # Manually add source to xarray.DataArray encoding to make the GMT accessors work.
        if source:
            grid.encoding["source"] = source
    

    pygmt>6.5

    fname = f"@{prefix}_{resolution}_{reg}"
        grid = xr.load_dataarray(
            fname, engine="gmt", raster_kind=dataset.kind, region=region
        )
    

    Those last lines make the code fail with resolutions 01s and 03s. I agree that they might not exist on GEBCO servers, but then why was it working before? Which data was is using? In that case, I can find a workaround. igpp data are messing all my codes up, because it's not the same kind of datum : I need the ocean floor.

  14. seisman commented on Dec 5, 2025

    @seisman
    Member

    Which data was it using?

    It uses the @earth_relief_03s dataset, which is exactly what you'll use when setting data_source="igpp".

    This can be confirmed by the following GMT CLI commands:

    $ gmt grdinfo @earth_relief_03s -R120/121/40/41 -G
    grdblend [NOTICE]: Remote data courtesy of GMT data server oceania [http://oceania.generic-mapping-tools.org]
    
    grdblend [NOTICE]: Earth Relief at 3x3 arc seconds tiles provided by SRTMGL3 (land only) [NASA/USGS].
    grdblend [NOTICE]:   -> Download 1x1 degree grid tile (earth_relief_03s_g): N40E120
    
    $ gmt grdinfo @earth_gebco_03s -R120/121/40/41 -G
    grdblend [NOTICE]: Remote data courtesy of GMT data server oceania [http://oceania.generic-mapping-tools.org]
    
    grdblend [NOTICE]: Earth Relief at 3x3 arc seconds tiles provided by SRTMGL3 (land only) [NASA/USGS].
    grdblend [NOTICE]:   -> Download 1x1 degree grid tile (earth_relief_03s_g): N40E120
    grdblend [NOTICE]: SRTM15 Earth Relief v2.7 original at 15x15 arc seconds [Tozer et al., 2019].
    grdblend [NOTICE]:   -> Download 10x10 degree grid tile (earth_relief_15s_p): N40E120
    
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bug

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions