pygmt.grdpaste

pygmt.grdpaste(grid1, grid2, outgrid=None, verbose=False, **kwargs)[source]

Join two grids along their common edge.

Combine grid1 and grid2 into a single grid by pasting them together along their common edge. The two input grids must have the same grid spacings and registration, and must have one edge in common. If in doubt, check with pygmt.grdinfo and use pygmt.grdcut and/or pygmt.grdsample if necessary to prepare the edge joint. Note: For geographical grids, you may have to use coltypes to handle periodic longitudes unless the input grids are properly recognized as such via their meta-data. For stitching multiple grids, see grdblend (not implemented in PyGMT yet) instead.

Full GMT docs at https://docs.generic-mapping-tools.org/6.6/grdpaste.html.

Aliases:

  • f = coltypes

  • G = outgrid

  • V = verbose

Parameters:
Return type:

DataArray | None

Returns:

ret – Return type depends on whether the outgrid parameter is set:

  • xarray.DataArray if outgrid is not set

  • None if outgrid is set (grid output will be stored in the file set by outgrid)

Example

>>> import pygmt
>>> # Create two grids with a common edge
>>> # Grid 1: longitude range of 10° E to 20° E, latitude range of 15° N to 25° N
>>> grid1 = pygmt.datasets.load_earth_relief(
...     resolution="30m", region=[10, 20, 15, 25]
... )
>>> # Grid 2: longitude range of 10° E to 20° E, latitude range of 10° N to 15° N
>>> grid2 = pygmt.datasets.load_earth_relief(
...     resolution="30m", region=[10, 20, 10, 15]
... )
>>> # Paste the two grids together along their common edge (15° N)
>>> new_grid = pygmt.grdpaste(grid1=grid1, grid2=grid2)