1GMTCONVERT(1) Generic Mapping Tools GMTCONVERT(1)
2
3
4
6 gmtconvert - Converts, Pastes, and/or Extracts columns from ASCII and
7 binary 1-D tables
8
10 gmtconvert [ inputfiles ] [ -A ] [ -D[template] ] [ -E[f|l] ] [ -Fcols
11 ] [ -H[i][nrec] ] [ -L ] [ -I ] [ -N ] [ -S[~]"search string") ] [ -V ]
12 [ -:[i|o] ] [ -b[i|o][s|S|d|D[ncol]|c[var1/...]] ] [ -f[i|o]colinfo ] [
13 -g[a]x|y|d|X|Y|D|[col]z[+|-]gap[u] ] [ -m[i|o][flag] ]
14
16 gmtconvert reads its standard input [or inputfiles] and writes out the
17 desired information to standard output. It can do a combination of
18 three things: (1) convert between binary and ASCII data tables, (2)
19 paste corresponding records from multiple files into a single file, (3)
20 extract a subset of the columns, (4) only extract segments whose header
21 matches a text pattern search, (5) just list all multisegment headers
22 and no data records, and (6) extract first and last data record for
23 each segment. Input (and hence output) may have multiple subheaders if
24 -m is selected, and ASCII tables may have regular headers as well.
25
26 datafile(s)
27 ASCII (or binary, see -bi) file(s) holding a number of data col‐
28 umns.
29
31 -A The records from the input files should be pasted horizontally,
32 not appended vertically. [Default processes one file at the
33 time]. Note for binary input, all the files you want to paste
34 must have the same number of columns (as set with -bi).
35
36 -D For multiple segment data, dump each segment to a separate out‐
37 put file [Default writes a multiple segment file to stdout].
38 Append a format template for the individual file names; this
39 template must contain a C format specifier that can format an
40 integer argument (the segment number); this is usually %d but
41 could be %8.8d which gives leading zeros, etc. [Default is gmt‐
42 convert_segment_%d.d].
43
44 -E Only extract the first and last record for each segment of
45 interest [Default extracts all records]. Optionally, append f
46 or l to only extract the first or last record of each segment,
47 respectively.
48
49 -F Give a comma-separated list of desired columns or ranges (0 is
50 first column) [Default outputs all columns].
51
52 -H Input file(s) has header record(s). If used, the default number
53 of header records is N_HEADER_RECS. Use -Hi if only input data
54 should have header records [Default will write out header
55 records if the input data have them]. Blank lines and lines
56 starting with # are always skipped.
57
58 -I Invert the order of rows, i.e., output the final records in
59 reverse order, starting with the last and ending up with the
60 first input row [Default goes forward].
61
62 -L Only output a listing of all multisegment header records and no
63 data records (requires -m and ASCII data).
64
65 -N Do not write records that only contain NaNs in every field
66 [Default writes all records].
67
68 -S Only output those segments whose header record contains the
69 specified text string. To reverse the search, i.e., to output
70 segments whose headers do not contain the specified pattern, use
71 -S~. Should your pattern happen to start with ~ you need to
72 escape this character with a backslash [Default output all seg‐
73 ments].
74
75 -V Selects verbose mode, which will send progress reports to stderr
76 [Default runs "silently"].
77
78 -: Toggles between (longitude,latitude) and (latitude,longitude)
79 input and/or output. [Default is (longitude,latitude)]. Append
80 i to select input only or o to select output only. [Default
81 affects both].
82
83 -bi Selects binary input. Append s for single precision [Default is
84 d (double)]. Uppercase S or D will force byte-swapping.
85 Optionally, append ncol, the number of columns in your binary
86 input file if it exceeds the columns needed by the program. Or
87 append c if the input file is netCDF. Optionally, append
88 var1/var2/... to specify the variables to be read.
89
90 -bo Selects binary output. Append s for single precision [Default
91 is d (double)]. Uppercase S or D will force byte-swapping.
92 Optionally, append ncol, the number of desired columns in your
93 binary output file. [Default is same as input].
94
95 -f Special formatting of input and/or output columns (time or geo‐
96 graphical data). Specify i or o to make this apply only to
97 input or output [Default applies to both]. Give one or more
98 columns (or column ranges) separated by commas. Append T (abso‐
99 lute calendar time), t (relative time in chosen TIME_UNIT since
100 TIME_EPOCH), x (longitude), y (latitude), or f (floating point)
101 to each column or column range item. Shorthand -f[i|o]g means
102 -f[i|o]0x,1y (geographic coordinates).
103
104 -g Examine the spacing between consecutive data points in order to
105 impose breaks in the line. Append x|X or y|Y to define a gap
106 when there is a large enough change in the x or y coordinates,
107 respectively, or d|D for distance gaps; use upper case to calcu‐
108 late gaps from projected coordinates. For gap-testing on other
109 columns use [col]z; if col is not prepended the it defaults to 2
110 (i.e., 3rd column). Append [+|-]gap and optionally a unit u.
111 Regarding optional signs: -ve means previous minus current col‐
112 umn value must exceed |gap to be a gap, +ve means current minus
113 previous column value must exceed gap, and no sign means the
114 absolute value of the difference must exceed gap. For geo‐
115 graphic data (x|y|d), the unit u may be meter [Default], kilome‐
116 ter, miles, or nautical miles. For projected data (X|Y|D),
117 choose from inch, centimeter, meter, or points [Default unit set
118 by MEASURE_UNIT]. Note: For x|y|z with time data the unit is
119 instead controlled by TIME_UNIT. Repeat the option to specify
120 multiple criteria, of which any can be met to produce a line
121 break. Issue an additional -ga to indicate that all criteria
122 must be met instead.
123
124 -m Multiple segment file(s). Segments are separated by a special
125 record. For ASCII files the first character must be flag
126 [Default is '>']. For binary files all fields must be NaN and
127 -b must set the number of output columns explicitly. By default
128 the -m setting applies to both input and output. Use -mi and
129 -mo to give separate settings to input and output.
130
132 The ASCII output formats of numerical data are controlled by parameters
133 in your .gmtdefaults4 file. Longitude and latitude are formatted
134 according to OUTPUT_DEGREE_FORMAT, whereas other values are formatted
135 according to D_FORMAT. Be aware that the format in effect can lead to
136 loss of precision in the output, which can lead to various problems
137 downstream. If you find the output is not written with enough preci‐
138 sion, consider switching to binary output (-bo if available) or specify
139 more decimals using the D_FORMAT setting.
140
142 To convert the binary file test.b (single precision) with 4 columns to
143 ASCII:
144
145 gmtconvert test.b -bis4 > test.dat
146
147 To convert the multiple segment ASCII table test.d to a double preci‐
148 sion binary file:
149
150 gmtconvert test.d -m -bo > test.b
151
152 You have an ASCII table with 6 columns and you want to plot column 5
153 versus column 0. Try
154
155 gmtconvert table.d -F5,0 | psxy ...
156
157 If the file instead is the binary file results.b which has 9 single-
158 precision values per record, we extract the last column and columns 4-6
159 and write ASCII with the command
160
161 gmtconvert results.b -F8,4-6 -bi9s | psxy ...
162
163 You want to plot the 2nd column of a 2-column file left.d versus the
164 first column of a file right.d:
165
166 gmtconvert left.d right.d -A -F1,2 | psxy ...
167
168 To extract all segments in the file big_file.d whose headers contain
169 the string "RIDGE AXIS", try
170
171 gmtconvert big_file.d -m -S"RIDGE AXIS" > subset.d
172
174 GMT(1), minmax(1)
175
176
177
178GMT 4.5.6 10 Mar 2011 GMTCONVERT(1)