pygmt.grdproject¶
- pygmt.grdproject(grid, *, outgrid=None, projection=None, inverse=None, region=None, verbose=None, interpolation=None, registration=None, **kwargs)[source]¶
Change projection of gridded data between geographical and rectangular.
This module will project a geographical gridded data set onto a rectangular grid. If
inverse
isTrue
, it will project a rectangular coordinate system to a geographic system. To obtain the value at each new node, its location is inversely projected back onto the input grid after which a value is interpolated between the surrounding input grid values. By default bi-cubic interpolation is used. Aliasing is avoided by also forward projecting the input grid nodes. If two or more nodes are projected onto the same new node, their average will dominate in the calculation of the new node value. Interpolation and aliasing is controlled with theinterpolation
option. The new node spacing may be determined in one of several ways by specifying the grid spacing, number of nodes, or resolution. Nodes not constrained by input data are set to NaN. Theregion
parameter can be used to select a map region larger or smaller than that implied by the extent of the grid file.Aliases:
G = outgrid
I = inverse
J = projection
R = region
V = verbose
n = interpolation
r = registration
- Parameters
grid (str or xarray.DataArray) – The file name of the input grid or the grid loaded as a DataArray.
outgrid (str or None) – The name of the output netCDF file with extension .nc to store the grid in.
inverse (bool) – When set to
True
transforms grid from rectangular to geographical [Default is False].projection (str) – Required if this is the first plot command. projcode[projparams/]width. Select map projection.
region (str or list) – Required if this is the first plot command. xmin/xmax/ymin/ymax[+r][+uunit]. Specify the region of interest.
Select verbosity level [Default is w], which modulates the messages written to stderr. Choose among 7 levels of verbosity:
q - Quiet, not even fatal error messages are produced
e - Error messages only
w - Warnings [Default]
t - Timings (report runtimes for time-intensive algorithms);
i - Informational messages (same as
verbose=True
)c - Compatibility warnings
d - Debugging messages
interpolation (str) –
[b|c|l|n][+a][+bBC][+c][+tthreshold]. Select interpolation mode for grids. You can select the type of spline used:
b for B-spline
c for bicubic [Default]
l for bilinear
n for nearest-neighbor
registration (str) – g|p. Force gridline (g) or pixel (p) node registration. [Default is g(ridline)].
- Returns
ret (xarray.DataArray or None) – Return type depends on whether the
outgrid
parameter is set:xarray.DataArray
ifoutgrid
is not setNone if
outgrid
is set (grid output will be stored in file set byoutgrid
)