Trouble to get Global Earth Relief Grids

Hello everybody

I am new to GMT. I have success in installing gmt in spyder (anaconda python). I ha download the grids with the following command in sypder (IDE of python)

import pygmt as gmt

#gmt.show_versions()
region = [15, 115, 15, 70]
#region = [10, 20, 35, 45]

grid = gmt.datasets.load_earth_relief(resolution='06m')  

There is no problem, but i want to download relief ‘05m’ or ‘04m’…or ‘01s’
with

grid = gmt.datasets.load_earth_relief(resolution='05m', region=region) 

it is sent the following error:

grdblend [ERROR]: Cannot find file Diaz/.gmt/sessions/gmt_session.14804/
grdcut [ERROR]: ERROR - Unable to produce blended grid from C:/Users/Adrian Diaz/.gmt/sessions/gmt_session.14804/=tiled_84_GX.000000
[Session pygmt-session (3)]: Error returned from GMT API: GMT_GRID_READ_ERROR (18)
[Session pygmt-session (3)]: Error returned from GMT API: GMT_GRID_READ_ERROR (18)
Traceback (most recent call last):

  File "D:\fold_AEDM_DoctoradoCI_PUC\FOLD_Cursos_Doctorado\fold_ING5250_Autoria-Articulo_Publicacion-Revista\fold_RA-Outline_CDP0006\fold_Figuras\Figure_1\fold_Fig1_GMT\importar_grd_files_gmtpy.py", line 25, in <module>
    grid = gmt.datasets.load_earth_relief(resolution='05m', region=region)  ##  raise GMTInvalidInput

  File "C:\Users\Adrian Diaz\.conda\envs\pygmt\lib\site-packages\pygmt\helpers\decorators.py", line 557, in new_module
    return module_func(*args, **kwargs)

  File "C:\Users\Adrian Diaz\.conda\envs\pygmt\lib\site-packages\pygmt\datasets\earth_relief.py", line 140, in load_earth_relief
    grid = grdcut(f"@{earth_relief_prefix}{resolution}{reg}", region=region)

  File "C:\Users\Adrian Diaz\.conda\envs\pygmt\lib\site-packages\pygmt\helpers\decorators.py", line 414, in new_module
    return module_func(*args, **kwargs)

  File "C:\Users\Adrian Diaz\.conda\envs\pygmt\lib\site-packages\pygmt\helpers\decorators.py", line 557, in new_module
    return module_func(*args, **kwargs)

  File "C:\Users\Adrian Diaz\.conda\envs\pygmt\lib\site-packages\pygmt\src\grdcut.py", line 102, in grdcut
    with xr.open_dataarray(outgrid) as dataarray:

  File "C:\Users\Adrian Diaz\.conda\envs\pygmt\lib\site-packages\xarray\backends\api.py", line 653, in open_dataarray
    dataset = open_dataset(

  File "C:\Users\Adrian Diaz\.conda\envs\pygmt\lib\site-packages\xarray\backends\api.py", line 480, in open_dataset
    engine = plugins.guess_engine(filename_or_obj)

  File "C:\Users\Adrian Diaz\.conda\envs\pygmt\lib\site-packages\xarray\backends\plugins.py", line 111, in guess_engine
    raise ValueError(

ValueError: did not find a match in any of xarray's currently installed IO backends ['netcdf4']. Consider explicitly selecting one of the installed backends via the ``engine`` parameter to xarray.open_dataset(), or installing additional IO dependencies:

I would appreciate your help

        Greetings Adrián

The reason is that you have a space in your directory name which causes trouble with command-line arguments. GMT was developed as a UNIX tool so there are still assumptions in part of the code that there would not be spaces, as that leads to having to escape paths with quotes throughout. Hopefully, the PyGMT folks can help me find where this is happening so we can have a look.

PyGMT uses the which module to download >=06m grids and uses the grdcut module to download <=05m grids.

grdblend [ERROR]: Cannot find file Diaz/.gmt/sessions/gmt_session.14804/
grdcut [ERROR]: ERROR - Unable to produce blended grid from C:/Users/Adrian Diaz/.gmt/sessions/gmt_session.14804/=tiled_84_GX.000000
[Session pygmt-session (3)]: Error returned from GMT API: GMT_GRID_READ_ERROR (18)
[Session pygmt-session (3)]: Error returned from GMT API: GMT_GRID_READ_ERROR (18)
Traceback (most recent call last):

It seems a problem for grdblend, right? Perhaps @pwessel can try if you can blend grids that have whitespaces in their paths?

The first error comes from being unable to open the session directory so taht is before grdblend tries to do work.
I will create a user account with a space in it and install/build/test GMT there.

This will take some time since macOS wont let us create a user account with a space in the home dir name - I guess Windows thinks it is a good idea.

I can reproduce the error with gmt grdcut @earth_relief_05m -R15/115/15/70 -Gtest.nc with a space in the path and will work on debugging.

@aedmpygmt, the fastest solution for your purposes would be to change your user name to not have any spaces in it. This would prevent future problems related to the space, which the anaconda installation warns about. You would need to update any absolute file paths that you have previously assigned.

I friend

Thanks for your answer. I would not like to change any previous update any path, because I have installed very critical programs, and I prefer to avoid any problems.

¿Is there an alternative way to download the global earth relief from the GMT web site within “grid = gmt.datasets.load_earth_relief(resolution=‘06m’)”? I mean, by FTP in Linux for example?

The others program fro the GMT library works well in my spyder

               Greetings Adrián

         Greeting Adrián

Hi @aedmpygmtm, you can try downloading the earth relief grid using one of the “Data Server Mirrors” listed on https://www.generic-mapping-tools.org/mirrors/. Get the earth_relief_06m.grd and put it in your current project folder.

Hi wieji14

Thanks a lot, I have followed your tips for downloading and putting in a current project folder. The GMT works ok.

         Best regards Adrián
1 Like