SYNOPSIS

grd2xyz grdfile [ -H[nrec] ] [ -L ] [ -Rwest/east/south/north[r] [ -S[r ] [ -V ] [ -Z[flags] ] [ -bo[s][n] ]

DESCRIPTION

grd2xyz reads a binary 2-D grdfile and writes out xyz-triplets in ASCII [or binary] format to standard output. Modify the precision of the ASCII output format by editing the D_FORMAT parameter in your .gmtdefaults file, or choose binary output using single or double precision storage. As an option you may output z-values without the (x,y) in a number of formats, see -Z below.

grdfile

The 2-D binary file to be converted.

OPTIONS

-H

Output 1 header record based on information in the grdfile header. Ignored if binary output is selected. [Default is no header].

-L

Indicates that the x values are longitudes (necessary for -: to work).

-R

west, east, south, and north specify the Region of interest. To specify boundaries in degrees and minutes [and seconds], use the dd:mm[:ss] format. Append r if lower left and upper right map coordinates are given instead of wesn.

-S

Suppress output for nodes whose z-value equals NaN [Default outputs all nodes]. Append r to reverse the suppression, i.e., only output the nodes whose z-value equals NaN.

-V

Selects verbose mode, which will send progress reports to stderr [Default runs "silently"].

-Z

Write a 1-column ASCII [or binary] table. Output will be organized 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 outcoming 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):

        a ASCII representation
        c signed 1-byte character
        u unsigned 1-byte character
        h short 2-byte integer
        i 4-byte integer
        l long (4- or 8-byte) integer
        f 4-byte floating point single precision
        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

Selects binary output. Append s for single precision [Default is double]. This option only applies to xyz output; see -Z for z table output.

EXAMPLES

To edit individual values in the 5' by 5' hawaii_grv.grd file, try

grd2xyz hawaii_grv.grd > hawaii_grv.xyz

To write a single precision binary file without the x,y positions from the file raw_data.grd file, using scanline orientation, try

grd2xyz raw_data.grd -ZTLf > hawaii_grv.b

RELATED TO grd2xyz…

gmtdefaults(1gmt), gmt(1gmt), grdedit(1gmt), xyz2grd(1gmt)