grdclip¶
Clip the range of grid values
Synopsis¶
gmt grdclip ingrid -Goutgrid [ -Rregion ] [ -Sahigh/above ] [ -Sblow/below ] [ -Silow/high/between ] [ -Srold/new ] [ -V[level] ] [ --PAR=value ]
Note: No space is allowed between the option flag and the associated arguments.
Description¶
grdclip will set values < low to below and/or values > high to above. You can also specify one or more intervals where all values should be set to between, or replace individual values. Such operations are useful when you want all of a continent or an ocean to fall into one color or gray shade in image processing, when clipping of the range of data values is required, or for reclassification of data values. above, below, between, old and new can be any number or even NaN (Not a Number). You must choose at least one of the -S options. Use -R to only extract a subset of the ingrid file.
Required Arguments¶
ingrid[=ID|?varname][+bband][+ddivisor][+ninvalid] [+ooffset][+sscale]
The input 2-D binary 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.
-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.
Optional Arguments¶
- -Rxmin/xmax/ymin/ymax[+r][+uunit]
Specify the region of interest. Using the -R option will select a subsection of ingrid grid. If this subsection exceeds the boundaries of the grid, only the common region will be extracted. (See full description) (See cookbook information).
- -Sahigh/above
Set all data[i] > high to above.
- -Sblow/below
Set all data[i] < low to below.
- -Silow/high/between
Set all data[i] >= low and <= high to between. Repeat the option for as many intervals as are needed.
- -Srold/new
Set all data[i] == old to new. This is mostly useful when your data are known to be integer values. Repeat the option for as many replacements as are needed.
- -V[level]
Select verbosity level [w]. (See full description) (See cookbook information).
- -^ 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.
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 set all values > 0 to NaN and all values < 0 to 0 in the remote file AFR.nc:
gmt grdclip @AFR.nc -Gnew_AFR.nc -Sa0/NaN -Sb0/0 -V
To reclassify all values in the 25-30 range to 99, those in 35-39 to 55, exchange 17 for 11 and all values < 10 to 0 in file classes.nc, try
gmt grdclip classes.nc -Gnew_classes.nc -Si25/30/99 -Si35/39/55 -Sr17/11 -Sb10/0 -V
See Also¶
gmt, grdfill, grdlandmask, grdmask, grdmath, grd2xyz, xyz2grd