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

NAME

6       xyz2grd - Converting an ASCII or binary table to grid file format
7

SYNOPSIS

9       xyz2grd     xyzfile    -Ggrdfile    -Ixinc[unit][=|+][/yinc[unit][=|+]]
10       -Rwest/east/south/north[r]       [        -A[n|z|u|l]        ]        [
11       -Dxname/yname/zname/scale/offset/title/remark ] [ -E[nodata] ] [ -F ] [
12       -H[i][nrec] ] [ -Nnodata ] [ -S[zfile] ] [ -V ] [ -Z[flags] ] [ -:[i|o]
13       ] [ -bi[s|S|d|D[ncol]|c[var1/...]] ] [ -fcolinfo ]
14

DESCRIPTION

16       xyz2grd reads a z or xyz table and creates a binary grid file.  xyz2grd
17       will report if some of the nodes are not filled  in  with  data.   Such
18       unconstrained  nodes  are set to a value specified by the user [Default
19       is NaN].  Nodes with more than one value will be  set  to  the  average
20       value.   As an option (using -Z), a 1-column z-table may be read assum‐
21       ing all nodes are present (z-tables can be in organized in a number  of
22       formats, see -Z below.)
23
24       [xy]zfile
25              ASCII  [or  binary]  file  holding  z  or  (x,y,z)  values.  xyz
26              triplets do not have to be sorted (for binary triplets, see -b).
27              1-column z tables must be sorted and the -Z must be set).
28
29       -G     grdfile  is  the name of the binary output grid file.  (See GRID
30              FILE FORMAT below.)
31
32       -I     x_inc [and optionally y_inc] is the  grid  spacing.  Optionally,
33              append  a  suffix modifier.  Geographical (degrees) coordinates:
34              Append m to indicate arc minutes or c to indicate  arc  seconds.
35              If  one  of  the  units  e,  k, i, or n is appended instead, the
36              increment is assumed to be given in meter, km, miles, or  nauti‐
37              cal miles, respectively, and will be converted to the equivalent
38              degrees longitude at the middle latitude of the region (the con‐
39              version  depends on ELLIPSOID).  If /y_inc is given but set to 0
40              it will be reset equal to x_inc; otherwise it will be  converted
41              to degrees latitude.  All coordinates: If = is appended then the
42              corresponding max x (east) or y (north) may be slightly adjusted
43              to fit exactly the given increment [by default the increment may
44              be adjusted slightly to fit the given domain].  Finally, instead
45              of  giving  an  increment  you  may  specify the number of nodes
46              desired by appending + to the  supplied  integer  argument;  the
47              increment  is then recalculated from the number of nodes and the
48              domain.  The resulting increment value depends  on  whether  you
49              have  selected  a  gridline-registered or pixel-registered grid;
50              see Appendix B for details.  Note: if  -Rgrdfile  is  used  then
51              grid  spacing  has  already been initialized; use -I to override
52              the values.
53
54       -R     xmin, xmax, ymin, and ymax specify the Region of interest.   For
55              geographic  regions,  these  limits  correspond  to  west, east,
56              south, and north and you may specify them in decimal degrees  or
57              in  [+-]dd:mm[:ss.xxx][W|E|S|N]  format.  Append r if lower left
58              and upper right map coordinates are given  instead  of  w/e/s/n.
59              The  two  shorthands  -Rg and -Rd stand for global domain (0/360
60              and -180/+180 in longitude respectively, with -90/+90  in  lati‐
61              tude).  Alternatively, specify the name of an existing grid file
62              and the -R settings (and grid spacing, if applicable) are copied
63              from  the  grid.   For  calendar time coordinates you may either
64              give (a) relative time (relative to the selected TIME_EPOCH  and
65              in  the  selected TIME_UNIT; append t to -JX|x), or (b) absolute
66              time of the form [date]T[clock] (append T to -JX|x).   At  least
67              one of date and clock must be present; the T is always required.
68              The date string must be of the form [-]yyyy[-mm[-dd]] (Gregorian
69              calendar) or yyyy[-Www[-d]] (ISO week calendar), while the clock
70              string must be of the form hh:mm:ss[.xxx].  The  use  of  delim‐
71              iters  and their type and positions must be exactly as indicated
72              (however, input, output and plot formats are  customizable;  see
73              gmtdefaults).
74

OPTIONS

76       -A     Add  up  multiple  values  that belong to the same node (same as
77              -Az).  Append n to simply count the number of data  points  that
78              were  assigned  to  each node.  Append l or u to find the lowest
79              (minimum) or upper (maximum) value at each  node,  respectively.
80              [Default  (no -A option) will calculate mean value].  Ignored if
81              -Z is given.
82
83       -D     Give values for xname, yname, zname, scale, offset,  title,  and
84              remark.   To  leave some of these values untouched, specify = as
85              the value.  Alternatively, to allow "/" to be part of one of the
86              values,  use  any  non-alphanumeric character (and not the equal
87              sign) as separator by both starting  and  ending  with  it.  For
88              example: -D:xname:yname:zname:scale:offset:title:remark:
89
90       -E     Convert  an ESRI ArcInfo ASCII interchange grid format file to a
91              GMT grid.  Append nodata which is a data value  that  should  be
92              set  to  NaN  in the grid [If we find the optional 6th record in
93              the file we will use it instead].  The values normally given  by
94              -R, -I, and -F are determined from the ESRI header instead.
95
96       -F     Force  pixel  node  registration  [Default is gridline registra‐
97              tion].  (Node registrations are defined in GMT Cookbook Appendix
98              B on grid file formats.)
99
100       -H     Input file(s) has header record(s).  If used, the default number
101              of header records is N_HEADER_RECS.  Use -Hi if only input  data
102              should  have  header  records  [Default  will  write  out header
103              records if the input data have  them].  Blank  lines  and  lines
104              starting with # are always skipped.  Not used with binary data.
105
106       -N     No  data.   Set  nodes  with  no input xyz triplet to this value
107              [Default is NaN].  For z-tables, this option is used to  replace
108              z-values that equal nodata with NaN.
109
110       -S     Swap  the  byte-order  of  the input only.  No grid file is pro‐
111              duced.  You must also supply the -Z option.  The output is writ‐
112              ten to zfile (or stdout if not supplied).
113
114       -V     Selects verbose mode, which will send progress reports to stderr
115              [Default runs "silently"].
116
117       -Z     Read a 1-column ASCII [or binary] table.  This assumes that  all
118              the nodes are present and sorted according to specified ordering
119              convention contained in  flags.   If  incoming  data  represents
120              rows,  make  flags  start with T(op) if first row is y = ymax or
121              B(ottom) if first row is y = ymin.  Then, append L or R to indi‐
122              cate  that  first element is at left or right end of row.  Like‐
123              wise for column formats: start with L or  R  to  position  first
124              column,  and  then  append T or B to position first element in a
125              row.  For gridline registered grids:  If data are periodic in  x
126              but the incoming data do not contain the (redundant) column at x
127              = xmax, append x.  For data periodic in y without redundant  row
128              at  y = ymax, append y.  Append sn to skip the first n number of
129              bytes (probably a  header).   If  the  byte-order  needs  to  be
130              swapped, append w.  Select one of several data types (all binary
131              except a):
132
133                   A  ASCII representation of one or more floating point  val‐
134              ues per record
135
136                   a  ASCII representation of a single item per record
137                   c  signed 1-byte character
138                   u  unsigned 1-byte character
139                   h  short 2-byte integer
140                   i  4-byte integer
141                   l  long (4- or 8-byte) integer [architecture-dependent!]
142                   f  4-byte floating point single precision
143                   d  8-byte floating point double precision
144
145              Default  format is scanline orientation of ASCII numbers: -ZTLa.
146              Note that -Z only applies to  1-column  input.   The  difference
147              between  A  and  a is that the latter can decode both dateTclock
148              and ddd:mm:ss[.xx] formats while the former is strictly for reg‐
149              ular floating point values.
150
151       -:     Toggles  between  (longitude,latitude)  and (latitude,longitude)
152              input and/or output.  [Default is (longitude,latitude)].  Append
153              i  to  select  input  only or o to select output only.  [Default
154              affects both].
155
156       -bi    Selects binary input.  Append s for single precision [Default is
157              d  (double)].   Uppercase  S  or  D  will  force  byte-swapping.
158              Optionally, append ncol, the number of columns  in  your  binary
159              input  file if it exceeds the columns needed by the program.  Or
160              append c  if  the  input  file  is  netCDF.  Optionally,  append
161              var1/var2/...  to specify the variables to be read.  [Default is
162              3 input columns].  This option only applies to xyz input  files;
163              see -Z for z tables.
164
165       -f     Special  formatting of input and/or output columns (time or geo‐
166              graphical data).  Specify i or o to  make  this  apply  only  to
167              input  or  output  [Default  applies to both].  Give one or more
168              columns (or column ranges) separated by commas.  Append T (abso‐
169              lute  calendar time), t (relative time in chosen TIME_UNIT since
170              TIME_EPOCH), x (longitude), y (latitude), or f (floating  point)
171              to  each  column or column range item.  Shorthand -f[i|o]g means
172              -f[i|o]0x,1y (geographic coordinates).
173

GRID VALUES PRECISION

175       Regardless of the precision of the input data, GMT programs that create
176       grid  files  will  internally  hold  the grids in 4-byte floating point
177       arrays.  This is done to conserve memory and furthermore  most  if  not
178       all  real  data can be stored using 4-byte floating point values.  Data
179       with higher precision (i.e., double precision values)  will  lose  that
180       precision  once  GMT  operates on the grid or writes out new grids.  To
181       limit loss of precision when processing data you should always consider
182       normalizing the data prior to processing.
183

GRID FILE FORMATS

185       By  default GMT writes out grid as single precision floats in a COARDS-
186       complaint netCDF file format.  However, GMT is  able  to  produce  grid
187       files  in  many  other commonly used grid file formats and also facili‐
188       tates so called "packing" of grids, writing out floating point data  as
189       2-  or 4-byte integers. To specify the precision, scale and offset, the
190       user should add the suffix =id[/scale/offset[/nan]], where id is a two-
191       letter  identifier of the grid type and precision, and scale and offset
192       are optional scale factor and offset to be applied to all grid  values,
193       and nan is the value used to indicate missing data.  See grdreformat(1)
194       and Section 4.17 of the GMT Technical Reference and Cookbook  for  more
195       information.
196
197       When  writing  a  netCDF  file,  the grid is stored by default with the
198       variable name "z". To specify another  variable  name  varname,  append
199       ?varname  to  the file name.  Note that you may need to escape the spe‐
200       cial meaning of ? in your shell program by putting a backslash in front
201       of  it,  or by placing the filename and suffix between quotes or double
202       quotes.
203

GEOGRAPHICAL AND TIME COORDINATES

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

EXAMPLES

215       To create a grid file from the ASCII data in hawaii_grv.xyz, use
216
217       xyz2grd    hawaii_grv.xyz    -Ddegree/degree/mGal/1/0/"Hawaiian   Grav‐
218       ity"/"GRS-80 Ellipsoid used" -Ghawaii_grv_new.grd -R198/208/18/25  -I5m
219       -V
220
221       To  create a grid file from the raw binary (3-column, single-precision)
222       scanline-oriented data raw.b, use
223
224       xyz2grd raw.b -Dm/m/m/1/0/=/= -Graw.grd -R0/100/0/100 -I1 -V -Z -b3
225
226       To make a grid file from the raw binary USGS DEM (short integer)  scan‐
227       line-oriented  data topo30. on the NGDC global relief Data CD-ROM, with
228       values of -9999 indicate missing data, one must on some machine reverse
229       the byte-order.  On such machines (like Sun), use
230
231       xyz2grd  topo30.  -Dm/m/m/1/0/=/=  -Gustopo.grd  -R234/294/24/50  -I30c
232       -N-9999 -B -ZTLhw
233
234       Say you have received a binary file with 4-byte  floating  points  that
235       were  written on a machine of different byte-order than yours.  You can
236       swap the byte-order with
237
238       xyz2grd floats.bin -Snew_floats.bin -V -Zf
239

SEE ALSO

241       GMT(1), grd2xyz(1), grdedit(1)
242
243
244
245GMT 4.5.6                         10 Mar 2011                       XYZ2GRD(1)
Impressum