# Pygmt.datasets.load\_earth\_relief("05m", region=\[116.5, 117.5, 22.8, 23.5\]) return indexerror

**URL:** <https://forum.generic-mapping-tools.org/t/pygmt-datasets-load-earth-relief-05m-region-116-5-117-5-22-8-23-5-return-indexerror/5554>\
**Category:** PyGMT Q&A\
**Created:** [November 25, 2024, 2:07pm UTC](https://forum.generic-mapping-tools.org/t/pygmt-datasets-load-earth-relief-05m-region-116-5-117-5-22-8-23-5-return-indexerror/5554 "2024-11-25T14:07:58Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![guofenxiwu](https://yyz1.discourse-cdn.com/flex047/user_avatar/forum.generic-mapping-tools.org/guofenxiwu/32/4582_2.png) [@guofenxiwu](https://forum.generic-mapping-tools.org/u/guofenxiwu)\
**Post date:** [November 25, 2024, 2:07pm UTC](https://forum.generic-mapping-tools.org/t/pygmt-datasets-load-earth-relief-05m-region-116-5-117-5-22-8-23-5-return-indexerror/5554/1 "2024-11-25T14:07:58Z")

</div>

Dear all:

This is my code:

```auto
import pygmt
grid = pygmt.datasets.load_earth_relief(resolution="05m", region=[-92.5, -82.5, -3, 7])

```

but it returned the error:

```auto
[Session pygmt-session (27)]: Error returned from GMT API: GMT_FILE_NOT_FOUND (16)
[Session pygmt-session (27)]: Error returned from GMT API: GMT_GRID_READ_ERROR (18)
[Session pygmt-session (27)]: Error returned from GMT API: GMT_GRID_READ_ERROR (18)

IndexError Traceback (most recent call last)
Cell In[10], line 4
      1 import pygmt
      3 # Load sample earth relief data
----> 4 grid = pygmt.datasets.load_earth_relief(resolution="05m", region=[-92.5, -82.5, -3, 7])

File D:\anaconda\envs\pygmt\Lib\site-packages\pygmt\helpers\decorators.py:773, in kwargs_to_strings.<locals>.converter.<locals>.new_module(*args, **kwargs)
    770 bound.arguments["kwargs"][arg] = newvalue
    772 # Execute the original function and return its output
--> 773 return module_func(*bound.args, **bound.kwargs)

File D:\anaconda\envs\pygmt\Lib\site-packages\pygmt\datasets\earth_relief.py:168, in load_earth_relief(resolution, region, registration, data_source, use_srtm)
    166 case "gebco" | "gebcosi":
    167 name = "earth_gebco"
--> 168 grid = _load_remote_dataset(
    169 name=name,
    170 prefix=prefix,
    171 resolution=resolution,
    172 region=region,
    173 registration=registration,
    174 )
    175 return grid

File D:\anaconda\envs\pygmt\Lib\site-packages\pygmt\helpers\decorators.py:773, in kwargs_to_strings.<locals>.converter.<locals>.new_module(*args, **kwargs)
    770 bound.arguments["kwargs"][arg] = newvalue
    772 # Execute the original function and return its output
--> 773 return module_func(*bound.args, **bound.kwargs)

File D:\anaconda\envs\pygmt\Lib\site-packages\pygmt\datasets\load_remote_dataset.py:418, in _load_remote_dataset(name, prefix, resolution, region, registration)
    413 with lib.virtualfile_out(kind="grid") as voutgrd:
    414 lib.call_module(
    415 module="read",
    416 args=[fname, voutgrd, *build_arg_list(kwdict)],
    417 )
--> 418 grid = lib.virtualfile_to_raster(outgrid=None, vfname=voutgrd)
    420 # Full path to the grid if not tiled grids.
    421 source = which(fname, download="a") if not resinfo.tiled else None

File D:\anaconda\envs\pygmt\Lib\site-packages\pygmt\clib\session.py:2021, in Session.virtualfile_to_raster(self, vfname, kind, outgrid)
   2015 family = self.inquire_virtualfile(vfname)
   2016 kind = { # type: ignore[assignment]
   2017 self["GMT_IS_GRID"]: "grid",
   2018 self["GMT_IS_IMAGE"]: "image",
   2019 self["GMT_IS_CUBE"]: "cube",
   2020 }[family]
-> 2021 return self.read_virtualfile(vfname, kind=kind).contents.to_dataarray()

File D:\anaconda\envs\pygmt\Lib\site-packages\pygmt\datatypes\grid.py:192, in _GMT_GRID.to_dataarray(self)
    188 # Flip the coordinates and data if necessary so that coordinates are ascending.
    189 # `grid.sortby(list(grid.dims))` sometimes causes crashes.
    190 # The solution comes from https://github.com/pydata/xarray/discussions/6695.
    191 for dim in grid.dims:
--> 192 if grid[dim][0] > grid[dim][1]:
    193 grid = grid.isel({dim: slice(None, None, -1)})
    195 # Set GMT accessors.
    196 # Must put at the end, otherwise info gets lost after certain grid operations.

File D:\anaconda\envs\pygmt\Lib\site-packages\xarray\core\dataarray.py:901, in DataArray. __getitem__ (self, key)
    898 return self._getitem_coord(key)
    899 else:
    900 # xarray-style array indexing
--> 901 return self.isel(indexers=self._item_key_to_dict(key))

File D:\anaconda\envs\pygmt\Lib\site-packages\xarray\core\dataarray.py:1540, in DataArray.isel(self, indexers, drop, missing_dims, **indexers_kwargs)
   1535 return self._from_temp_dataset(ds)
   1537 # Much faster algorithm for when all indexers are ints, slices, one-dimensional
   1538 # lists, or zero or one-dimensional np.ndarray's
-> 1540 variable = self._variable.isel(indexers, missing_dims=missing_dims)
   1541 indexes, index_variables = isel_indexes(self.xindexes, indexers)
   1543 coords = {}

File D:\anaconda\envs\pygmt\Lib\site-packages\xarray\core\variable.py:1049, in Variable.isel(self, indexers, missing_dims, **indexers_kwargs)
   1046 indexers = drop_dims_from_indexers(indexers, self.dims, missing_dims)
   1048 key = tuple(indexers.get(dim, slice(None)) for dim in self.dims)
-> 1049 return self[key]

File D:\anaconda\envs\pygmt\Lib\site-packages\xarray\core\variable.py:816, in Variable. __getitem__ (self, key)
    813 dims, indexer, new_order = self._broadcast_indexes(key)
    814 indexable = as_indexable(self._data)
--> 816 data = indexing.apply_indexer(indexable, indexer)
    818 if new_order:
    819 data = np.moveaxis(data, range(len(new_order)), new_order)

File D:\anaconda\envs\pygmt\Lib\site-packages\xarray\core\indexing.py:1033, in apply_indexer(indexable, indexer)
   1031 return indexable.oindex[indexer]
   1032 else:
-> 1033 return indexable[indexer]

File D:\anaconda\envs\pygmt\Lib\site-packages\xarray\core\indexing.py:1798, in PandasIndexingAdapter. __getitem__ (self, indexer)
   1795 indexable = NumpyIndexingAdapter(np.asarray(self))
   1796 return indexable[indexer]
-> 1798 result = self.array[key]
   1800 return self._handle_result(result)

File D:\anaconda\envs\pygmt\Lib\site-packages\pandas\core\indexes\base.py:5389, in Index. __getitem__ (self, key)
   5386 if is_integer(key) or is_float(key):
   5387 # GH#44051 exclude bool, which would return a 2d ndarray
   5388 key = com.cast_scalar_indexer(key)
-> 5389 return getitem(key)
   5391 if isinstance(key, slice):
   5392 # This case is separated from the conditional above to avoid
   5393 # pessimization com.is_bool_indexer and ndim checks.
   5394 return self._getitem_slice(key)

IndexError: index 0 is out of bounds for axis 0 with size 0

```

How can I deal with it？

---

<div class="post-metadata">

**Author:** ![yvonnefroehlich](https://yyz1.discourse-cdn.com/flex047/user_avatar/forum.generic-mapping-tools.org/yvonnefroehlich/32/5064_2.png) [@yvonnefroehlich](https://forum.generic-mapping-tools.org/u/yvonnefroehlich)\
**Post date:** [November 25, 2024, 3:07pm UTC](https://forum.generic-mapping-tools.org/t/pygmt-datasets-load-earth-relief-05m-region-116-5-117-5-22-8-23-5-return-indexerror/5554/2 "2024-11-25T15:07:10Z")

</div>

Hello @guofenxiwu,

Welcome to the GMT forum 🙂!

Hm. Can you please post the output of `pygmt.show_versions()`.  
Did you try other resolutions, e.g,`"01d"` or `"30m"` as well as other datasets, e.g., `pygmt.datasets.load_earth_age`? Does this also not work?

---

<div class="post-metadata">

**Author:** ![guofenxiwu](https://yyz1.discourse-cdn.com/flex047/user_avatar/forum.generic-mapping-tools.org/guofenxiwu/32/4582_2.png) [@guofenxiwu](https://forum.generic-mapping-tools.org/u/guofenxiwu)\
**Post date:** [November 25, 2024, 3:56pm UTC](https://forum.generic-mapping-tools.org/t/pygmt-datasets-load-earth-relief-05m-region-116-5-117-5-22-8-23-5-return-indexerror/5554/3 "2024-11-25T15:56:54Z")

</div>

![image](https://canada1.discourse-cdn.com/flex047/uploads/gmt/original/2X/c/c98f05236cf1853749b7637bef3cee69ec57949e.png)  
here is my version

---

<div class="post-metadata">

**Author:** ![guofenxiwu](https://yyz1.discourse-cdn.com/flex047/user_avatar/forum.generic-mapping-tools.org/guofenxiwu/32/4582_2.png) [@guofenxiwu](https://forum.generic-mapping-tools.org/u/guofenxiwu)\
**Post date:** [November 25, 2024, 4:07pm UTC](https://forum.generic-mapping-tools.org/t/pygmt-datasets-load-earth-relief-05m-region-116-5-117-5-22-8-23-5-return-indexerror/5554/4 "2024-11-25T16:07:31Z")

</div>

'‘06m’, ‘01d’ and ‘30m’ datasets work but the ‘05m’ or higher dimensions does not work.

---

<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:** [November 26, 2024, 2:33am UTC](https://forum.generic-mapping-tools.org/t/pygmt-datasets-load-earth-relief-05m-region-116-5-117-5-22-8-23-5-return-indexerror/5554/5 "2024-11-26T02:33:18Z")

</div>

It’s likely internet connection issues and GMT fails to download the grid tiles.

---

<div class="post-metadata">

**Author:** ![guofenxiwu](https://yyz1.discourse-cdn.com/flex047/user_avatar/forum.generic-mapping-tools.org/guofenxiwu/32/4582_2.png) [@guofenxiwu](https://forum.generic-mapping-tools.org/u/guofenxiwu)\
**Post date:** [November 26, 2024, 2:59am UTC](https://forum.generic-mapping-tools.org/t/pygmt-datasets-load-earth-relief-05m-region-116-5-117-5-22-8-23-5-return-indexerror/5554/6 "2024-11-26T02:59:02Z")

</div>

Thank you sir! you’re right.
