grdfill

Interpolate across holes in a grid

Synopsis

gmt grdfill ingrid [ -Ac|n|s[arg] ] [ -Goutgrid ] [ -L[p] ] [ -Nvalue ] [ -Rregion ] [ -V[level] ] [ -fflags ] [ --PAR=value ]

Note: No space is allowed between the option flag and the associated arguments.

Description

grdfill reads 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 -N. There are several different algorithms that can be used to replace the hole values. Note: One of -A or -L is required.

Required Arguments

ingrid[=ID|?varname][+bband][+ddivisor][+ninvalid] [+ooffset][+sscale]

This is the input grid file. Optionally, append =ID for reading a specific file format [Default is =nf] or ?varname for a specific netCDF variable [Default is the first 2-D grid found by GMT] (See full description). The following modifiers are supported:

  • +b - Select a band (for images only) [Default is 0].

  • +d - Divide data values by the given divisor [Default is 1].

  • +n - Replace data values matching invalid with NaN.

  • +o - Offset data values by the given offset [Default is 0].

  • +s - Scale data values by the given scale [Default is 1].

Note: Any offset is added after any scaling.

Optional Arguments

-Ac|n|s[arg]

Specify the hole-filling algorithm to use. Choose among c for constant fill (and append the constant fill value), n for nearest neighbor (and optionally append a search radius in pixels [default radius is \(r = \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 [no tension]).

-Goutgrid[=ID][+ddivisor][+ninvalid] [+ooffset|a][+sscale|a] [:driver[dataType][+coptions]]

Give the name of the output grid file. Optionally, append =ID for writing a specific file format (See full description). The following modifiers are supported:

  • +d - Divide data values by given divisor [Default is 1].

  • +n - Replace data values matching invalid with a NaN.

  • +o - Offset data values by the given offset, or append a for automatic range offset to preserve precision for integer grids [Default is 0].

  • +s - Scale data values by the given scale, or append a for automatic scaling to preserve precision for integer grids [Default is 1].

Note: Any offset is added before any scaling. +sa also sets +oa (unless overridden). To write specific formats via GDAL, use = gd and supply driver (and optionally dataType) and/or one or more concatenated GDAL -co options using +c. See the “Writing grids and images” cookbook section for more details.

-N[nodata]

Sets the node value used to identify a point as a member of a hole [Default is NaN].

-Rxmin/xmax/ymin/ymax[+r][+uunit]

Specify the region of interest. This defines the subregion to be cut out. (See full description) (See cookbook information).

-L[p]

Just list the rectangular subregions west east south north of each hole. No grid fill takes place and -G is ignored. Optionally, append p to instead write closed polygons for all subregions.

-V[level]

Select verbosity level [w]. (See full description) (See cookbook information).

-f[i|o]colinfo (more …)

Specify data types of input and/or output columns.

-^ or just -

Print a short message about the syntax of the command, then exit (NOTE: on Windows just use -).

-+ or just +

Print an extensive usage (help) message, including the explanation of any module-specific option (but not the GMT common options), then exit.

-? or no arguments

Print a complete usage (help) message, including the explanation of all options, then exit.

--PAR=value

Temporarily override a GMT default setting; repeatable. See gmt.conf for parameters.

Geographical And Time Coordinates

When the output grid type is netCDF, the coordinates will be labeled “longitude”, “latitude”, or “time” based on the attributes of the input data or grid (if any) or on the -f or -R options. For example, both -f0x -f1t and -R90w/90e/0t/3t will result in a longitude/time grid. When the x, y, or z coordinate is time, it will be stored in the grid as relative time since epoch as specified by TIME_UNIT and TIME_EPOCH in the gmt.conf file or on the command line. In addition, the unit attribute of the time variable will indicate both this unit and epoch.

Examples

Note: Below are some examples of valid syntax for this module. The examples that use remote files (file names starting with @) can be cut and pasted into your terminal for testing. Other commands requiring input files are just dummy examples of the types of uses that are common but cannot be run verbatim as written.

To identify all regions with NaNs in the grid data.grd and create a listing of the bounding coordinates of rectangular regions that would cover these NaN areas, try:

gmt grdfill data.grd -L > wesn_listing.txt

To identify the same areas but this time write a multisegment file with polygons corresponding to the rectangular subregions, use:

gmt grdfill data.grd -Lp > NaN_regions.txt

To replace all NaN values in the file data.grd with the value 999.0, use:

gmt grdfill data.grd -Ac999 -Gno_NaNs_data.grd

To replace all NaN values in the file data.grd with the values at the nearest non-NaN neighbor, try:

gmt grdfill data.grd -An -Gno_NaNs_NN_data.grd

To replace all NaN values in the file data.grd with a spline interpolation using a tension of 0.2, try:

gmt grdfill data.grd -As0.2 -Gno_NaNs_spline_data.grd