1GRDSAMPLE(1) Generic Mapping Tools GRDSAMPLE(1)
2
3
4
6 grdsample - Resample a grid file onto a new grid
7
9 grdsample in_grdfile -Gout_grdfile [ -F ] [
10 -Ixinc[unit][=|+][/yinc[unit][=|+]] ] [ -Lflag ] [
11 -Q[b|c|l|n][[/]threshold] ] [ -Rwest/east/south/north[r] ] [ -T ] [ -V
12 ] [ -fcolinfo ]
13
15 grdsample reads a grid file and interpolates it to create a new grid
16 file with either: a different registration (-F or -T); or, a new grid-
17 spacing or number of nodes (-I), and perhaps also a new sub-region
18 (-R). A bicubic [Default], bilinear, B-spline or nearest-neighbor
19 interpolation (-Q) is used, requiring boundary conditions (-L). Note
20 that using -R only is equivalent to grdcut or grdedit -S. grdsample
21 safely creates a fine mesh from a coarse one; the converse may suffer
22 aliasing unless the data are filtered using grdfft or grdfilter.
23
24 When -R is omitted, the output grid will cover the same region as the
25 input grid. When -I is omitted, the grid spacing of the output grid
26 will be the same as the input grid. Either -F or -T can be used to
27 change the grid registration. When omitted, the output grid will have
28 the same registration as the input grid.
29
30 in_grdfile
31 The name of the input 2-D binary grid file. (See GRID FILE FOR‐
32 MAT below.)
33
34 -G The name of the output grid file. (See GRID FILE FORMAT below.)
35
37 -F Force pixel node registration on output grid. [Default is same
38 registration as input grid].
39
40 -I x_inc [and optionally y_inc] is the grid spacing. Optionally,
41 append a suffix modifier. Geographical (degrees) coordinates:
42 Append m to indicate arc minutes or c to indicate arc seconds.
43 If one of the units e, k, i, or n is appended instead, the
44 increment is assumed to be given in meter, km, miles, or nauti‐
45 cal miles, respectively, and will be converted to the equivalent
46 degrees longitude at the middle latitude of the region (the con‐
47 version depends on ELLIPSOID). If /y_inc is given but set to 0
48 it will be reset equal to x_inc; otherwise it will be converted
49 to degrees latitude. All coordinates: If = is appended then the
50 corresponding max x (east) or y (north) may be slightly adjusted
51 to fit exactly the given increment [by default the increment may
52 be adjusted slightly to fit the given domain]. Finally, instead
53 of giving an increment you may specify the number of nodes
54 desired by appending + to the supplied integer argument; the
55 increment is then recalculated from the number of nodes and the
56 domain. The resulting increment value depends on whether you
57 have selected a gridline-registered or pixel-registered grid;
58 see Appendix B for details. Note: if -Rgrdfile is used then
59 grid spacing has already been initialized; use -I to override
60 the values.
61
62 -L Boundary condition flag may be x or y or xy indicating data is
63 periodic in range of x or y or both set by -R, or flag may be g
64 indicating geographical conditions (x and y are lon and lat).
65 [Default uses "natural" conditions (second partial derivative
66 normal to edge is zero) unless the grid is automatically recog‐
67 nised as periodic.]
68
69 -Q Quick mode, use bilinear rather than bicubic interpolation
70 [Default]. Alternatively, select the interpolation mode by
71 adding b for B-spline smoothing, c for bicubic interpolation, l
72 for bilinear interpolation or n for nearest-neighbor value.
73 Optionally, append threshold in the range [0,1]. This parameter
74 controls how close to nodes with NaN values the interpolation
75 will go. E.g., a threshold of 0.5 will interpolate about half
76 way from a non-NaN to a NaN node, whereas 0.1 will go about 90%
77 of the way, etc. [Default is 1, which means none of the (4 or
78 16) nearby nodes may be NaN]. -Q0 will just return the value of
79 the nearest node instead of interpolating. This is the same as
80 using -Qn.
81
82 -R xmin, xmax, ymin, and ymax specify the Region of interest. For
83 geographic regions, these limits correspond to west, east,
84 south, and north and you may specify them in decimal degrees or
85 in [+-]dd:mm[:ss.xxx][W|E|S|N] format. Append r if lower left
86 and upper right map coordinates are given instead of w/e/s/n.
87 The two shorthands -Rg and -Rd stand for global domain (0/360
88 and -180/+180 in longitude respectively, with -90/+90 in lati‐
89 tude). Alternatively, specify the name of an existing grid file
90 and the -R settings (and grid spacing, if applicable) are copied
91 from the grid. For calendar time coordinates you may either
92 give (a) relative time (relative to the selected TIME_EPOCH and
93 in the selected TIME_UNIT; append t to -JX|x), or (b) absolute
94 time of the form [date]T[clock] (append T to -JX|x). At least
95 one of date and clock must be present; the T is always required.
96 The date string must be of the form [-]yyyy[-mm[-dd]] (Gregorian
97 calendar) or yyyy[-Www[-d]] (ISO week calendar), while the clock
98 string must be of the form hh:mm:ss[.xxx]. The use of delim‐
99 iters and their type and positions must be exactly as indicated
100 (however, input, output and plot formats are customizable; see
101 gmtdefaults).
102
103 -T Translate between grid and pixel registration; if the input is
104 grid-registered, the output will be pixel-registered and vice-
105 versa.
106
107 -V Selects verbose mode, which will send progress reports to stderr
108 [Default runs "silently"].
109
110 -f Special formatting of input and/or output columns (time or geo‐
111 graphical data). Specify i or o to make this apply only to
112 input or output [Default applies to both]. Give one or more
113 columns (or column ranges) separated by commas. Append T (abso‐
114 lute calendar time), t (relative time in chosen TIME_UNIT since
115 TIME_EPOCH), x (longitude), y (latitude), or f (floating point)
116 to each column or column range item. Shorthand -f[i|o]g means
117 -f[i|o]0x,1y (geographic coordinates).
118
120 Regardless of the precision of the input data, GMT programs that create
121 grid files will internally hold the grids in 4-byte floating point
122 arrays. This is done to conserve memory and furthermore most if not
123 all real data can be stored using 4-byte floating point values. Data
124 with higher precision (i.e., double precision values) will lose that
125 precision once GMT operates on the grid or writes out new grids. To
126 limit loss of precision when processing data you should always consider
127 normalizing the data prior to processing.
128
130 By default GMT writes out grid as single precision floats in a COARDS-
131 complaint netCDF file format. However, GMT is able to produce grid
132 files in many other commonly used grid file formats and also facili‐
133 tates so called "packing" of grids, writing out floating point data as
134 2- or 4-byte integers. To specify the precision, scale and offset, the
135 user should add the suffix =id[/scale/offset[/nan]], where id is a two-
136 letter identifier of the grid type and precision, and scale and offset
137 are optional scale factor and offset to be applied to all grid values,
138 and nan is the value used to indicate missing data. When reading
139 grids, the format is generally automatically recognized. If not, the
140 same suffix can be added to input grid file names. See grdreformat(1)
141 and Section 4.17 of the GMT Technical Reference and Cookbook for more
142 information.
143
144 When reading a netCDF file that contains multiple grids, GMT will read,
145 by default, the first 2-dimensional grid that can find in that file. To
146 coax GMT into reading another multi-dimensional variable in the grid
147 file, append ?varname to the file name, where varname is the name of
148 the variable. Note that you may need to escape the special meaning of ?
149 in your shell program by putting a backslash in front of it, or by
150 placing the filename and suffix between quotes or double quotes. The
151 ?varname suffix can also be used for output grids to specify a variable
152 name different from the default: "z". See grdreformat(1) and Section
153 4.18 of the GMT Technical Reference and Cookbook for more information,
154 particularly on how to read splices of 3-, 4-, or 5-dimensional grids.
155
157 If an interpolation point is not on a node of the input grid, then a
158 NaN at any node in the neighborhood surrounding the point will yield an
159 interpolated NaN. Bicubic interpolation [default] yields continuous
160 first derivatives but requires a neighborhood of 4 nodes by 4 nodes.
161 Bilinear interpolation [-Q] uses only a 2 by 2 neighborhood, but yields
162 only zeroth-order continuity. Use bicubic when smoothness is impor‐
163 tant. Use bilinear to minimize the propagation of NaNs.
164
166 To resample the 5 x 5 minute grid in hawaii_5by5_topo.grd onto a 1
167 minute grid:
168
169 grdsample hawaii_5by5_topo.grd -I1m -Ghawaii_1by1_topo.grd
170
171 To translate the gridline-registered file surface.grd to pixel regis‐
172 tration while keeping the same region and grid interval:
173
174 grdsample surface.grd -T -Gpixel.grd
175
177 GMT(1), grdedit(1), grdfft(1), grdfilter(1)
178
179
180
181GMT 4.5.6 10 Mar 2011 GRDSAMPLE(1)