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.
51
52       -R     xmin, xmax, ymin, and ymax specify the Region of interest.   For
53              geographic  regions,  these  limits  correspond  to  west, east,
54              south, and north and you may specify them in decimal degrees  or
55              in  [+-]dd:mm[:ss.xxx][W|E|S|N]  format.  Append r if lower left
56              and upper right map coordinates are given  instead  of  w/e/s/n.
57              The  two  shorthands  -Rg and -Rd stand for global domain (0/360
58              and -180/+180 in longitude respectively, with -90/+90  in  lati‐
59              tude).   For  calendar  time coordinates you may either give (a)
60              relative time (relative to the selected TIME_EPOCH  and  in  the
61              selected  TIME_UNIT; append t to -JX|x), or (b) absolute time of
62              the form [date]T[clock] (append T to -JX|x).  At  least  one  of
63              date  and  clock must be present; the T is always required.  The
64              date string must be of  the  form  [-]yyyy[-mm[-dd]]  (Gregorian
65              calendar) or yyyy[-Www[-d]] (ISO week calendar), while the clock
66              string must be of the form hh:mm:ss[.xxx].  The  use  of  delim‐
67              iters  and their type and positions must be exactly as indicated
68              (however, input, output and plot formats are  customizable;  see
69              gmtdefaults).
70

OPTIONS

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

GRID VALUES PRECISION

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

GRID FILE FORMATS

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

GEOGRAPHICAL AND TIME COORDINATES

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

EXAMPLES

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

SEE ALSO

232       GMT(1), grd2xyz(1), grdedit(1)
233
234
235
236GMT 4.3.1                         15 May 2008                       XYZ2GRD(1)
Impressum