1GRDSAMPLE(1)                 Generic Mapping Tools                GRDSAMPLE(1)
2
3
4

NAME

6       grdsample - Resample a grid file onto a new grid
7

SYNOPSIS

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

DESCRIPTION

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

OPTIONS

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.
59
60       -L     Boundary  condition  flag may be x or y or xy indicating data is
61              periodic in range of x or y or both set by -R, or flag may be  g
62              indicating  geographical  conditions  (x and y are lon and lat).
63              [Default uses "natural" conditions  (second  partial  derivative
64              normal  to edge is zero) unless the grid is automatically recog‐
65              nised as periodic.]
66
67       -Q     Quick mode,  use  bilinear  rather  than  bicubic  interpolation
68              [Default].   Alternatively,  select  the  interpolation  mode by
69              adding b for B-spline smooting, c for bicubic  interpolation,  l
70              for  bilinear  interpolation  or  n  for nearest-neighbor value.
71              Optionally, append threshold in the range [0,1].  This parameter
72              controls  how  close  to nodes with NaN values the interpolation
73              will go.  E.g., a threshold of 0.5 will interpolate  about  half
74              way  from a non-NaN to a NaN node, whereas 0.1 will go about 90%
75              of the way, etc. [Default is 1, which means none of  the  (4  or
76              16) nearby nodes may be NaN].  -Q0 will just return the value of
77              the nearest node instead of interpolating.  This is the same  as
78              using -Qn.
79
80       -R     xmin,  xmax, ymin, and ymax specify the Region of interest.  For
81              geographic regions,  these  limits  correspond  to  west,  east,
82              south,  and north and you may specify them in decimal degrees or
83              in [+-]dd:mm[:ss.xxx][W|E|S|N] format.  Append r if  lower  left
84              and  upper  right  map coordinates are given instead of w/e/s/n.
85              The two shorthands -Rg and -Rd stand for  global  domain  (0/360
86              and  -180/+180  in longitude respectively, with -90/+90 in lati‐
87              tude).  For calendar time coordinates you may  either  give  (a)
88              relative  time  (relative  to the selected TIME_EPOCH and in the
89              selected TIME_UNIT; append t to -JX|x), or (b) absolute time  of
90              the  form  [date]T[clock]  (append T to -JX|x).  At least one of
91              date and clock must be present; the T is always  required.   The
92              date  string  must  be  of the form [-]yyyy[-mm[-dd]] (Gregorian
93              calendar) or yyyy[-Www[-d]] (ISO week calendar), while the clock
94              string  must  be  of the form hh:mm:ss[.xxx].  The use of delim‐
95              iters and their type and positions must be exactly as  indicated
96              (however,  input,  output and plot formats are customizable; see
97              gmtdefaults).
98
99       -T     Translate between grid and pixel registration;  if the input  is
100              grid-registered,  the  output will be pixel-registered and vice-
101              versa.
102
103       -V     Selects verbose mode, which will send progress reports to stderr
104              [Default runs "silently"].
105
106       -f     Special  formatting of input and/or output columns (time or geo‐
107              graphical data).  Specify i or o to  make  this  apply  only  to
108              input  or  output  [Default  applies to both].  Give one or more
109              columns (or column ranges) separated by commas.  Append T (abso‐
110              lute  calendar time), t (relative time in chosen TIME_UNIT since
111              TIME_EPOCH), x (longitude), y (latitude), or f (floating  point)
112              to  each  column or column range item.  Shorthand -f[i|o]g means
113              -f[i|o]0x,1y (geographic coordinates).
114

GRID VALUES PRECISION

116       Regardless of the precision of the input data, GMT programs that create
117       gridded  files  will internally hold the grids in 4-byte floating point
118       arrays.  This is done to conserve memory and futhermore most if not all
119       real  data can be stored using 4-byte floating point values.  Data with
120       higher precision (i.e., double precision values) will lose that  preci‐
121       sion  once  GMT operates on the grid or writes out new grids.  To limit
122       loss of precision when processing data you should always consider  nor‐
123       malizing the data prior to processing.
124

GRID FILE FORMATS

126       By  default GMT writes out grid as single precision floats in a COARDS-
127       complaint netCDF file format.  However, GMT is  able  to  produce  grid
128       files  in  many  other commonly used grid file formats and also facili‐
129       tates so called "packing" of grids, writing out floating point data  as
130       2-  or 4-byte integers. To specify the precision, scale and offset, the
131       user should add the suffix =id[/scale/offset[/nan]], where id is a two-
132       letter  identifier of the grid type and precision, and scale and offset
133       are optional scale factor and offset to be applied to all grid  values,
134       and  nan  is  the  value  used  to indicate missing data.  When reading
135       grids, the format is generally automatically recognized.  If  not,  the
136       same  suffix can be added to input grid file names.  See grdreformat(1)
137       and Section 4.17 of the GMT Technical Reference and Cookbook  for  more
138       information.
139
140       When reading a netCDF file that contains multiple grids, GMT will read,
141       by default, the first 2-dimensional grid that can find in that file. To
142       coax  GMT  into  reading another multi-dimensional variable in the grid
143       file, append ?varname to the file name, where varname is  the  name  of
144       the variable. Note that you may need to escape the special meaning of ?
145       in your shell program by putting a backslash in  front  of  it,  or  by
146       placing  the  filename and suffix between quotes or double quotes.  The
147       ?varname suffix can also be used for output grids to specify a variable
148       name  different  from the default: "z".  See grdreformat(1) and Section
149       4.18 of the GMT Technical Reference and Cookbook for more  information,
150       particularly on how to read splices of 3-, 4-, or 5-dimensional grids.
151

HINTS

153       If  an  interpolation  point is not on a node of the input grid, then a
154       NaN at any node in the neighborhood surrounding the point will yield an
155       interpolated  NaN.   Bicubic  interpolation [default] yields continuous
156       first derivatives but requires a neighborhood of 4 nodes  by  4  nodes.
157       Bilinear interpolation [-Q] uses only a 2 by 2 neighborhood, but yields
158       only zeroth-order continuity.  Use bicubic when  smoothness  is  impor‐
159       tant.  Use bilinear to minimize the propagation of NaNs.
160

EXAMPLES

162       To  resample  the  5  x  5 minute grid in hawaii_5by5_topo.grd onto a 1
163       minute grid:
164
165       grdsample hawaii_5by5_topo.grd -I1m -Ghawaii_1by1_topo.grd
166
167       To translate the gridline-registered file surface.grd to  pixel  regis‐
168       tration while keeping the same region and grid interval:
169
170       grdsample surface.grd -T -Gpixel.grd
171

SEE ALSO

173       GMT(1), grdedit(1), grdfft(1), grdfilter(1)
174
175
176
177GMT 4.3.1                         15 May 2008                     GRDSAMPLE(1)
Impressum