# Merging grd files

**URL:** <https://forum.generic-mapping-tools.org/t/merging-grd-files/2294>\
**Category:** PyGMT Q&A\
**Created:** [November 11, 2021, 11:53pm UTC](https://forum.generic-mapping-tools.org/t/merging-grd-files/2294 "2021-11-11T23:53:24Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![madeleinelucas](https://avatars.discourse-cdn.com/v4/letter/m/e56c9b/32.png) [@madeleinelucas](https://forum.generic-mapping-tools.org/u/madeleinelucas)\
**Post date:** [November 11, 2021, 11:53pm UTC](https://forum.generic-mapping-tools.org/t/merging-grd-files/2294/1 "2021-11-11T23:53:24Z")

</div>

How would I merge two or more grid files in pyGMT? Would I use the grdcut and grdpaste commands like in GMT? I can’t find this in the documentation.

---

<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:** [November 12, 2021, 1:59am UTC](https://forum.generic-mapping-tools.org/t/merging-grd-files/2294/2 "2021-11-12T01:59:55Z")

</div>

PyGMT has `grdcut` (see [https://www.pygmt.org/v0.5.0/api/generated/pygmt.grdcut.html](https://www.pygmt.org/v0.5.0/api/generated/pygmt.grdcut.html)), but `grdpaste` is not wrapped yet. If you’re using Jupyter though, you can try a using an [exclamation mark](https://stackoverflow.com/questions/53498226/what-is-the-meaning-of-exclamation-and-question-marks-in-jupyter-notebook) to run GMT command, e.g. `!gmt grdpaste file_a.nc file_b.nc -Goutfile.nc -V -fg`.

Depending on how you want to merge your grid files though, there may be a way to do it using `xarray` too. See [https://xarray.pydata.org/en/v0.19.0/user-guide/combining.html](https://xarray.pydata.org/en/v0.19.0/user-guide/combining.html). Do you want to mosaic different tiles, concatenate along some dimension, take the mean of a stack of grids, etc? I’m assuming you’re working on the GMRT grids from [Importing GMRT data as a grid in pyGMT](https://flint.soest.hawaii.edu/t/importing-gmrt-data-as-a-grid-in-pygmt/2276)?

---

<div class="post-metadata">

**Author:** ![madeleinelucas](https://avatars.discourse-cdn.com/v4/letter/m/e56c9b/32.png) [@madeleinelucas](https://forum.generic-mapping-tools.org/u/madeleinelucas)\
**Post date:** [November 12, 2021, 5:10am UTC](https://forum.generic-mapping-tools.org/t/merging-grd-files/2294/3 "2021-11-12T05:10:50Z")

</div>

Hi @weiji14, thank you for all this! I ended up not needed to make a mosaic because I got the whole file downloaded - it seems like GMRT only allows downloads up to 1GB…

I do want to overlay/stack two bathymetry datasets though, do you know how to do this?

---

<div class="post-metadata">

**Author:** ![Andreas](https://avatars.discourse-cdn.com/v4/letter/a/ee7513/32.png) [@Andreas](https://forum.generic-mapping-tools.org/u/Andreas)\
**Post date:** [November 13, 2021, 10:56am UTC](https://forum.generic-mapping-tools.org/t/merging-grd-files/2294/4 "2021-11-13T10:56:57Z")

</div>

[https://docs.generic-mapping-tools.org/latest/grdblend.html](https://docs.generic-mapping-tools.org/latest/grdblend.html)?
