pygmt.grdfill
- pygmt.grdfill(grid, outgrid=None, **kwargs)[source]
Fill blank areas from a grid file.
Read a grid that presumably has unfilled holes that the user wants to fill in some fashion. Holes are identified by NaN values but this criteria can be changed via the
no_data
parameter. There are several different algorithms that can be used to replace the hole values.Full option list at https://docs.generic-mapping-tools.org/6.5/grdfill.html
Aliases:
A = mode
N = no_data
R = region
V = verbose
- Parameters:
grid (str or xarray.DataArray) –
Name of the input grid file or the grid loaded as a
xarray.DataArray
object.For reading a specific grid file format or applying basic data operations, see https://docs.generic-mapping-tools.org/6.5/gmt.html#grd-inout-full for the available modifiers.
outgrid (
str
|None
, default:None
) – Name of the output netCDF grid file. If not specified, will return anxarray.DataArray
object. For writing a specific grid file format or applying basic data operations to the output grid, see https://docs.generic-mapping-tools.org/6.5/gmt.html#grd-inout-full for the available modifiers.mode (str) – Specify the hole-filling algorithm to use. Choose from c for constant fill and append the constant value, n for nearest neighbor (and optionally append a search radius in pixels [default radius is \(r^2 = \sqrt{ X^2 + Y^2 }\), where (X,Y) are the node dimensions of the grid]), or s for bicubic spline (optionally append a tension parameter [Default is no tension]).
no_data (float) – Set the node value used to identify a point as a member of a hole [Default is NaN].
region (str or list) – 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
- Return type:
- Returns:
ret – 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
)
Example
>>> import pygmt >>> # Load a bathymetric grid with missing data >>> earth_relief_holes = pygmt.datasets.load_sample_data(name="earth_relief_holes") >>> # Perform grid filling operations on the sample grid >>> # Set all empty values to "20" >>> filled_grid = pygmt.grdfill(grid=earth_relief_holes, mode="c20")