# Trouble to get Global Earth Relief Grids

**URL:** <https://forum.generic-mapping-tools.org/t/trouble-to-get-global-earth-relief-grids/1924>\
**Category:** PyGMT Q&A\
**Created:** [July 25, 2021, 5:29pm UTC](https://forum.generic-mapping-tools.org/t/trouble-to-get-global-earth-relief-grids/1924 "2021-07-25T17:29:17Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![aedmpygmt](https://avatars.discourse-cdn.com/v4/letter/a/6f9a4e/32.png) [@aedmpygmt](https://forum.generic-mapping-tools.org/u/aedmpygmt)\
**Post date:** [July 25, 2021, 5:29pm UTC](https://forum.generic-mapping-tools.org/t/trouble-to-get-global-earth-relief-grids/1924/1 "2021-07-25T17:29:17Z")

</div>

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)

```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

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

```

_ **it is sent the following error:** _

```auto
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:

```

> **[Installation](https://docs.xarray.dev/en/stable/getting-started-guide/installing.html)**
>
> Required dependencies: Python (3.11 or later), numpy(1.26 or later), packaging(24.1 or later), pandas(2.2 or later). Optional dependencies: For netCDF and IO: netCDF4: recommended if you want to us...

> **[Reading and writing files](https://docs.xarray.dev/en/stable/user-guide/io.html)**
>
> Xarray supports direct serialization and IO to several file formats, from simple Pickle files to the more flexible netCDF format (recommended). You can read different types of files in xr.open\_data...

I would appreciate your help

```
        Greetings Adrián

```

---

<div class="post-metadata">

**Author:** ![pwessel](https://yyz1.discourse-cdn.com/flex047/user_avatar/forum.generic-mapping-tools.org/pwessel/32/30_2.png) [@pwessel](https://forum.generic-mapping-tools.org/u/pwessel)\
**Post date:** [July 25, 2021, 11:23pm UTC](https://forum.generic-mapping-tools.org/t/trouble-to-get-global-earth-relief-grids/1924/2 "2021-07-25T23:23:07Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![seisman](https://yyz1.discourse-cdn.com/flex047/user_avatar/forum.generic-mapping-tools.org/seisman/32/4_2.png) [@seisman](https://forum.generic-mapping-tools.org/u/seisman)\
**Post date:** [July 26, 2021, 2:27pm UTC](https://forum.generic-mapping-tools.org/t/trouble-to-get-global-earth-relief-grids/1924/3 "2021-07-26T14:27:19Z")

</div>

> [@aedmpygmt](#):
>
> 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)

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

```auto
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?

---

<div class="post-metadata">

**Author:** ![pwessel](https://yyz1.discourse-cdn.com/flex047/user_avatar/forum.generic-mapping-tools.org/pwessel/32/30_2.png) [@pwessel](https://forum.generic-mapping-tools.org/u/pwessel)\
**Post date:** [July 26, 2021, 7:51pm UTC](https://forum.generic-mapping-tools.org/t/trouble-to-get-global-earth-relief-grids/1924/4 "2021-07-26T19:51:24Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![pwessel](https://yyz1.discourse-cdn.com/flex047/user_avatar/forum.generic-mapping-tools.org/pwessel/32/30_2.png) [@pwessel](https://forum.generic-mapping-tools.org/u/pwessel)\
**Post date:** [July 26, 2021, 8:38pm UTC](https://forum.generic-mapping-tools.org/t/trouble-to-get-global-earth-relief-grids/1924/5 "2021-07-26T20:38:48Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![maxrjones](https://yyz1.discourse-cdn.com/flex047/user_avatar/forum.generic-mapping-tools.org/maxrjones/32/2698_2.png) [@maxrjones](https://forum.generic-mapping-tools.org/u/maxrjones)\
**Post date:** [July 26, 2021, 11:04pm UTC](https://forum.generic-mapping-tools.org/t/trouble-to-get-global-earth-relief-grids/1924/6 "2021-07-26T23:04:43Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![aedmpygmt](https://avatars.discourse-cdn.com/v4/letter/a/6f9a4e/32.png) [@aedmpygmt](https://forum.generic-mapping-tools.org/u/aedmpygmt)\
**Post date:** [July 28, 2021, 12:01am UTC](https://forum.generic-mapping-tools.org/t/trouble-to-get-global-earth-relief-grids/1924/7 "2021-07-28T00:01:08Z")

</div>

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
```

---

<div class="post-metadata">

**Author:** ![weiji14](https://yyz1.discourse-cdn.com/flex047/user_avatar/forum.generic-mapping-tools.org/weiji14/32/33_2.png) [@weiji14](https://forum.generic-mapping-tools.org/u/weiji14)\
**Post date:** [August 2, 2021, 11:56pm UTC](https://forum.generic-mapping-tools.org/t/trouble-to-get-global-earth-relief-grids/1924/8 "2021-08-02T23:56:36Z")

</div>

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/](https://www.generic-mapping-tools.org/mirrors/). Get the `earth_relief_06m.grd` and put it in your current project folder.

---

<div class="post-metadata">

**Author:** ![aedmpygmt](https://avatars.discourse-cdn.com/v4/letter/a/6f9a4e/32.png) [@aedmpygmt](https://forum.generic-mapping-tools.org/u/aedmpygmt)\
**Post date:** [August 3, 2021, 9:23pm UTC](https://forum.generic-mapping-tools.org/t/trouble-to-get-global-earth-relief-grids/1924/9 "2021-08-03T21:23:41Z")

</div>

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
```
