grd2xyz(1) GMT grd2xyz(1)
NAME
grd2xyz - Convert grid file to data table
SYNOPSIS
grd2xyz grid [ -C[f|i] ] [ -Rregion ] [ -V[level] ] [ -W[a|weight]
] [ -Z[flags] ] [ -bobinary ] [ -dnodata ] [ -fflags ] [ -ho[n] ] [
-oflags ] [ -sflags ]
Note: No space is allowed between the option flag and the associated
arguments.
DESCRIPTION
grd2xyz reads one or more binary 2-D grid files and writes out
xyz-triplets in ASCII [or binary] format to standard output. Modify the
precision of the ASCII output format by editing the FORMAT_FLOAT_OUT
parameter in your gmt.conf file or use --D_FORMAT=format on the command
line, or choose binary output using single or double precision storage.
As an option you may output z-values without the (x,y) coordinates; see
-Z below.
REQUIRED ARGUMENTS
grid Names of 2-D binary grid files to be converted. (See GRID FILE
FORMATS below.)
OPTIONAL ARGUMENTS
-C[f|i]
Replace the x- and y-coordinates on output with the correspond-
ing column and row numbers. These start at 0 (C-style counting);
append f to start at 1 (Fortran-style counting). Alternatively,
append i to write just the two columns index and z, where index
is the 1-D indexing that GMT uses when referring to grid nodes.
-Rxmin/xmax/ymin/ymax[+r][+uunit] (more a|)
Specify the region of interest. Using the -R option will select
a subsection of the grid. If this subsection exceeds the bound-
aries of the grid, only the common region will be output.
-V[level] (more a|)
Select verbosity level [c].
-W[a|weight]
Write out x,y,z,w, where w is the supplied weight (or 1 if not
supplied) [Default writes x,y,z only]. Choose -Wa to compute
weights equal to the area each node represents.
-Z[flags]
Write a 1-column ASCII [or binary] table. Output will be orga-
nized according to the specified ordering convention contained
in flags. If data should be written by rows, make flags start
with T (op) if first row is y = ymax or B (ottom) if first row
is y = ymin. Then, append L or R to indicate that first element
should start at left or right end of row. Likewise for column
formats: start with L or R to position first column, and then
append T or B to position first element in a row. For gridline
registered grids: If grid is periodic in x but the written data
should not contain the (redundant) column at x = xmax, append x.
For grid periodic in y, skip writing the redundant row at y =
ymax by appending y. If the byte-order needs to be swapped,
append w. Select one of several data types (all binary except
a):
o a ASCII representation of a single item per record
o c int8_t, signed 1-byte character
o u uint8_t, unsigned 1-byte character
o h int16_t, short 2-byte integer
o H uint16_t, unsigned short 2-byte integer
o i int32_t, 4-byte integer
o I uint32_t, unsigned 4-byte integer
o l int64_t, long (8-byte) integer
o L uint64_t, unsigned long (8-byte) integer
o f 4-byte floating point single precision
o d 8-byte floating point double precision
Default format is scanline orientation of ASCII numbers: -ZTLa.
Note that -Z only applies to 1-column output.
-bo[ncols][type] (more a|)
Select native binary output. [Default is 3]. This option only
applies to xyz output; see -Z for z table output.
-d[i|o]nodata (more a|)
Replace input columns that equal nodata with NaN and do the
reverse on output.
-f[i|o]colinfo (more a|)
Specify data types of input and/or output columns. See also TIME
COORDINATES below. -h Output 1 header record based on informa-
tion in the first grid file header. Ignored if binary output is
selected. [Default is no header].
-ocols[,a|] (more a|)
Select output columns (0 is first column).
-s[cols][a|r] (more a|)
Set handling of NaN records.
-^ or just -
Print a short message about the syntax of the command, then
exits (NOTE: on Windows just use -).
-+ or just +
Print an extensive usage (help) message, including the explana-
tion of any module-specific option (but not the GMT common
options), then exits.
-? or no arguments
Print a complete usage (help) message, including the explanation
of all options, then exits.
ASCII FORMAT PRECISION
The ASCII output formats of numerical data are controlled by parameters
in your gmt.conf file. Longitude and latitude are formatted according
to FORMAT_GEO_OUT, absolute time is under the control of FOR-
MAT_DATE_OUT and FORMAT_CLOCK_OUT, whereas general floating point val-
ues are formatted according to FORMAT_FLOAT_OUT. Be aware that the for-
mat in effect can lead to loss of precision in ASCII output, which can
lead to various problems downstream. If you find the output is not
written with enough precision, consider switching to binary output (-bo
if available) or specify more decimals using the FORMAT_FLOAT_OUT set-
ting.
GRID FILE FORMATS
By default GMT writes out grid as single precision floats in a
COARDS-complaint netCDF file format. However, GMT is able to produce
grid files in many other commonly used grid file formats and also
facilitates so called apackinga of grids, writing out floating point
data as 1- or 2-byte integers. (more a|)
TIME COORDINATES
Time coordinates in netCDF grids, be it the x, y, or z coordinate, will
be recognized as such. The variableas unit attribute is parsed to
determine the unit and epoch of the time coordinate in the grid. Values
are then converted to the internal time system specified by TIME_UNIT
and TIME_EPOCH in the gmt.conf file or on the command line. The default
output is relative time in that time system, or absolute time when
using the option -f0T, -f1T, or -f2T for x, y, or z coordinate, respec-
tively.
EXAMPLES
To edit individual values in the 5a by 5a hawaii_grv.nc file, dump the
.nc to ASCII:
gmt grd2xyz hawaii_grv.nc > hawaii_grv.xyz
To write a single precision binary file without the x,y positions from
the file raw_data.nc file, using scanline orientation, run
gmt grd2xyz raw_data.nc -ZTLf > hawaii_grv.b
SEE ALSO
gmt.conf(5), gmt(1), grdedit(1), grdconvert(1), xyz2grd(1)
COPYRIGHT
2017, P. Wessel, W. H. F. Smith, R. Scharroo, J. Luis, and F. Wobbe
5.4.2 Jun 24, 2017 grd2xyz(1)
gmt5 5.4.2 - Generated Wed Jun 28 18:10:40 CDT 2017
