pygmt.grdpaste
- pygmt.grdpaste(grid1, grid2, outgrid=None, verbose=False, **kwargs)[source]
Join two grids along their common edge.
Combine
grid1andgrid2into 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 withpygmt.grdinfoand usepygmt.grdcutand/orpygmt.grdsampleif necessary to prepare the edge joint. Note: For geographical grids, you may have to usecoltypesto handle periodic longitudes unless the input grids are properly recognized as such via their meta-data. For stitching multiple grids, seegrdblend(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:
grid2 (
str|PathLike|DataArray) – The two grids to be pasted. Each can be a file name or axarray.DataArrayobject.outgrid (
str|PathLike|None, default:None) – Name of the output netCDF grid file. If not specified, will return anxarray.DataArrayobject. For writing a specific grid file format or applying basic data operations to the output grid, see https://docs.generic-mapping-tools.org/6.6/gmt.html#grd-inout-full for the available modifiers.verbose (bool or str) – Select verbosity level [Full usage].
coltypes (str) – [i|o]colinfo. Specify data types of input and/or output columns (time or geographical data). Full documentation is at https://docs.generic-mapping-tools.org/6.6/gmt.html#f-full.
- Return type:
- Returns:
ret – Return type depends on whether the
outgridparameter is set:xarray.DataArrayifoutgridis not setNoneifoutgridis set (grid output will be stored in the file set byoutgrid)
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)