grd2xyz − Converting grdfile(s) to ASCII or binary data |
grd2xyz grdfiles [ −E[nodata] ] [ −H[i][nrec] ] [ −Rwest/east/south/north[r] ] [ −S[r] ] [ −V ] [ −W[weight] ] [ −Z[flags] ] [ −bo[s|S|d|D][ncol] ] [ −fcolinfo ] |
grd2xyz reads one or more binary 2-D grdfiles 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 .gmtdefaults4 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) in a number of formats, see −E or −Z below. |
grdfiles |
Names of 2-D binary grd files to be converted. |
−E |
Output an ESRI ArcInfo ASCII interchange grid format file. Append nodata which will be used wherever the grid value equals NaN [-9999]. Note that all data values are written as integers. |
||
−H |
Output 1 header record based on information in the first grdfile header. Ignored if binary output is selected. [Default is no header]. |
||
−R |
xmin, xmax, ymin, and ymax specify the Region of interest. For geographic regions, these limits correspond to west, east, south, and north and you may specify them in decimal degrees or in [+-]dd:mm[:ss.xxx][W|E|S|N] format. Append r if lower left and upper right map coordinates are given instead of wesn. The two shorthands −Rg −Rd stand for global domain (0/360 or -180/+180 in longitude respectively, with -90/+90 in latitude). For calendar time coordinates you may either give relative time (relative to the selected TIME_EPOCH and in the selected TIME_UNIT; append t to −JX|x), or absolute time of the form [date]T[clock] (append T to −JX|x). At least one of date and clock must be present; the T is always required. The date string must be of the form [-]yyyy[-mm[-dd]] (Gregorian calendar) or yyyy[-Www[-d]] (ISO week calendar), while the clock string must be of the form hh:mm:ss[.xxx]. The use of delimiters and their type and positions must be as indicated (however, input/output and plotting formats are flexible). |
||
−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"]. |
||
−W |
Write out x,y,z,w, where w is the supplied weight (or 1 if not supplied) [Default writes x,y,z only]. |
||
−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 |
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 d (double)]. Uppercase S (or D) will force byte-swapping. Optionally, append ncol, the number of desired columns in your binary output file. [Default is 3]. This option only applies to xyz output; see −Z for z table output. |
||
−f |
Special formatting of input and output columns (time or geographical data). Specify i(nput) or o(utput) [Default is both input and output]. Give one or more columns (or column ranges) separated by commas. Append T (Absolute calendar time), t (time relative to chosen TIME_EPOCH), x (longitude), y (latitude), or f (floating point) to each column or column range item. Shorthand −f[i|o]g means −f[i|o]0x,1y (geographic coordinates). |
The ASCII output formats of numerical data are controlled by parameters in your .gmtdefaults4 file. Longitude and latitude are formatted according to OUTPUT_DEGREE_FORMAT, whereas other values are formatted according to D_FORMAT. Be aware that the format in effect can lead to loss of precision in the 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 D_FORMAT setting. |
To edit individual values in the 5’ by 5’ hawaii_grv.grd file, dump the .grd to ASCII: 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, run grd2xyz raw_data.grd −ZTLf > hawaii_grv.b |
gmtdefaults(l), GMT(l), grdedit(l), xyz2grd(l) |