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

NAME

6       grd2xyz - Converting grid file(s) to ASCII or binary data
7

SYNOPSIS

9       grd2xyz    grdfiles    [    -E[nodata]    ]    [    -H[i][nrec]   ]   [
10       -Rwest/east/south/north[r] ] [  -S[r]  ]  [  -V  ]  [  -W[weight]  ]  [
11       -Z[flags] ] [ -bo[s|S|d|D[ncol]|c[var1/...]] ] [ -fcolinfo ]
12

DESCRIPTION

14       grd2xyz  reads  one  or  more binary 2-D grid files and writes out xyz-
15       triplets in ASCII [or binary] format to standard  output.   Modify  the
16       precision  of the ASCII output format by editing the D_FORMAT parameter
17       in your .gmtdefaults4 file or  use  --D_FORMAT=format  on  the  command
18       line, or choose binary output using single or double precision storage.
19       As an option you may output z-values without the (x,y) in a  number  of
20       formats, see -E or -Z below.
21
22       grdfiles
23              Names  of 2-D binary grid files to be converted.  (See GRID FILE
24              FORMATS below.)
25

OPTIONS

27       -E     Output an ESRI  ArcInfo  ASCII  interchange  grid  format  file.
28              Append  nodata which will be used wherever the grid value equals
29              NaN [-9999].  Note that all data values are written as integers.
30
31       -H     Output 1 header record based on information in  the  first  grid
32              file header.  Ignored if binary output is selected.  [Default is
33              no header].
34
35       -R     xmin, xmax, ymin, and ymax specify the Region of interest.   For
36              geographic  regions,  these  limits  correspond  to  west, east,
37              south, and north and you may specify them in decimal degrees  or
38              in  [+-]dd:mm[:ss.xxx][W|E|S|N]  format.  Append r if lower left
39              and upper right map coordinates are given  instead  of  w/e/s/n.
40              The  two  shorthands  -Rg and -Rd stand for global domain (0/360
41              and -180/+180 in longitude respectively, with -90/+90  in  lati‐
42              tude).   For  calendar  time coordinates you may either give (a)
43              relative time (relative to the selected TIME_EPOCH  and  in  the
44              selected  TIME_UNIT; append t to -JX|x), or (b) absolute time of
45              the form [date]T[clock] (append T to -JX|x).  At  least  one  of
46              date  and  clock must be present; the T is always required.  The
47              date string must be of  the  form  [-]yyyy[-mm[-dd]]  (Gregorian
48              calendar) or yyyy[-Www[-d]] (ISO week calendar), while the clock
49              string must be of the form hh:mm:ss[.xxx].  The  use  of  delim‐
50              iters  and their type and positions must be exactly as indicated
51              (however, input, output and plot formats are  customizable;  see
52              gmtdefaults).   Using  the -R option will select a subsection of
53              the grid. If this subsection exceeds the boundaries of the grid,
54              only the common region will be output.
55
56       -S     Suppress output for nodes whose z-value equals NaN [Default out‐
57              puts all nodes].  Append r to  reverse  the  suppression,  i.e.,
58              only output the nodes whose z-value equals NaN.
59
60       -V     Selects verbose mode, which will send progress reports to stderr
61              [Default runs "silently"].
62
63       -W     Write out x,y,z,w, where w is the supplied weight (or 1  if  not
64              supplied) [Default writes x,y,z only].
65
66       -Z     Write  a 1-column ASCII [or binary] table.  Output will be orga‐
67              nized according to the specified ordering  convention  contained
68              in  flags.   If data should be written by rows, make flags start
69              with T(op) if first row is y = ymax or B(ottom) if first row  is
70              y  =  ymin.   Then, append L or R to indicate that first element
71              should start at left or right end of row.  Likewise  for  column
72              formats:  start  with  L or R to position first column, and then
73              append T or B to position first element in a row.  For  gridline
74              registered  grids:   If  grid is periodic in x but the outcoming
75              data should not contain the (redundant)  column  at  x  =  xmax,
76              append  x.   For  grid periodic in y, skip writing the redundant
77              row at y = ymax by appending y.  If the byte-order needs  to  be
78              swapped, append w.  Select one of several data types (all binary
79              except a):
80
81              a  ASCII representation
82              c  signed 1-byte character
83              u  unsigned 1-byte character
84              h  short 2-byte integer
85              i  4-byte integer
86              l  long (4- or 8-byte) integer [architecture-dependent!]
87              f  4-byte floating point single precision
88              d  8-byte floating point double precision
89
90              Default format is scanline orientation of ASCII numbers:  -ZTLa.
91              Note that -Z only applies to 1-column output.
92
93       -bo    Selects  binary  output.  Append s for single precision [Default
94              is d (double)].  Uppercase S  or  D  will  force  byte-swapping.
95              Optionally,  append  ncol, the number of desired columns in your
96              binary output file.  [Default is 3].  This option  only  applies
97              to xyz output; see -Z for z table output.
98
99       -f     Special  formatting of input and/or output columns (time or geo‐
100              graphical data).  Specify i or o to  make  this  apply  only  to
101              input  or  output  [Default  applies to both].  Give one or more
102              columns (or column ranges) separated by commas.  Append T (abso‐
103              lute  calendar time), t (relative time in chosen TIME_UNIT since
104              TIME_EPOCH), x (longitude), y (latitude), or f (floating  point)
105              to  each  column or column range item.  Shorthand -f[i|o]g means
106              -f[i|o]0x,1y (geographic coordinates).  See  also  TIME  COORDI‐
107              NATES below.
108

ASCII FORMAT PRECISION

110       The ASCII output formats of numerical data are controlled by parameters
111       in your .gmtdefaults4  file.   Longitude  and  latitude  are  formatted
112       according  to  OUTPUT_DEGREE_FORMAT, whereas other values are formatted
113       according to D_FORMAT.  Be aware that the format in effect can lead  to
114       loss  of  precision  in  the output, which can lead to various problems
115       downstream.  If you find the output is not written with  enough  preci‐
116       sion, consider switching to binary output (-bo if available) or specify
117       more decimals using the D_FORMAT setting.
118

GRID FILE FORMATS

120       GMT is able to recognize many of the commonly used grid  file  formats,
121       as  well  as the precision, scale and offset of the values contained in
122       the grid file. When GMT needs a little help with that, you can add  the
123       suffix =id[/scale/offset[/nan]], where id is a two-letter identifier of
124       the grid type and precision, and scale and offset  are  optional  scale
125       factor  and  offset  to  be  applied to all grid values, and nan is the
126       value used to indicate missing data.  See  grdreformat(1)  and  Section
127       4.17 of the GMT Technical Reference and Cookbook for more information.
128
129       When reading a netCDF file that contains multiple grids, GMT will read,
130       by default, the first 2-dimensional grid that can find in that file. To
131       coax  GMT  into  reading another multi-dimensional variable in the grid
132       file, append ?varname to the file name, where varname is  the  name  of
133       the variable. Note that you may need to escape the special meaning of ?
134       in your shell program by putting a backslash in  front  of  it,  or  by
135       placing  the  filename and suffix between quotes or double quotes.  See
136       grdreformat(1) and Section 4.18 of  the  GMT  Technical  Reference  and
137       Cookbook  for  more information, particularly on how to read splices of
138       3-, 4-, or 5-dimensional grids.
139

TIME COORDINATES

141       Time coordinates in netCDF grids, be it the x, y, or z coordinate, will
142       be  recognized  as  such.   The  variable's unit attribute is parsed to
143       determine the unit and epoch of the time coordinate in the grid.   Val‐
144       ues  are  then  converted  to  the  internal  time  system specified by
145       TIME_UNIT and TIME_EPOCH in the .gmtdefaults file  or  on  the  command
146       line.   The  default  output  is  relative time in that time system, or
147       absolute time when using the option -f0T, -f1T, or -f2T for x, y, or  z
148       coordinate, respectively.
149

EXAMPLES

151       To edit individual values in the 5' by 5' hawaii_grv.grd file, dump the
152       .grd to ASCII:
153
154       grd2xyz hawaii_grv.grd > hawaii_grv.xyz
155
156       To write a single precision binary file without the x,y positions  from
157       the file raw_data.grd file, using scanline orientation, run
158
159       grd2xyz raw_data.grd -ZTLf > hawaii_grv.b
160

SEE ALSO

162       gmtdefaults(1), GMT(1), grdedit(1), xyz2grd(1)
163
164
165
166GMT 4.3.1                         15 May 2008                       GRD2XYZ(1)
Impressum