Register
Login
Resources
Docs Blog Datasets Glossary Case Studies Tutorials & Webinars
Product
Data Engine LLMs Platform Enterprise
Pricing Explore
Connect to our Discord channel

gmtconvert.rst 12 KB

You have to be logged in to leave a comment. Sign In
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
  1. .. index:: ! gmtconvert
  2. .. include:: module_core_purpose.rst_
  3. **********
  4. gmtconvert
  5. **********
  6. |gmtconvert_purpose|
  7. Synopsis
  8. --------
  9. .. include:: common_SYN_OPTs.rst_
  10. **gmt convert** [ *table* ]
  11. [ |-A| ]
  12. [ |-C|\ [**+l**\ *min*][**+u**\ *max*][**+i**]]
  13. [ |-D|\ [*template*\ [**+o**\ *orig*]] ]
  14. [ |-E|\ [**f**\|\ **l**\|\ **m**\|\ **M**\ *stride*] ]
  15. [ |-F|\ [**c**\|\ **n**\|\ **r**\|\ **v**][**a**\|\ **f**\|\ **s**\|\ **r**\|\ *refpoint*] ]
  16. [ |-I|\ [**tsr**] ]
  17. [ |-L| ]
  18. [ |-N|\ *col*\ [**+a**\|\ **d**] ]
  19. [ |-Q|\ [**~**]\ *selection*]
  20. [ |-S|\ [**~**]\ *"search string"* \| |-S|\ [**~**]/\ *regexp*/[**i**] ]
  21. [ |-T|\ [**h**\|\ **d**] ]
  22. [ |SYN_OPT-V| ]
  23. [ |-W|\ [**+n**] ]
  24. [ |SYN_OPT-a| ]
  25. [ |SYN_OPT-b| ]
  26. [ |SYN_OPT-d| ]
  27. [ |SYN_OPT-e| ]
  28. [ |SYN_OPT-f| ]
  29. [ |SYN_OPT-g| ]
  30. [ |SYN_OPT-h| ]
  31. [ |SYN_OPT-i| ]
  32. [ |SYN_OPT-o| ]
  33. [ |SYN_OPT-q| ]
  34. [ |SYN_OPT-s| ]
  35. [ |SYN_OPT-:| ]
  36. [ |SYN_OPT--| ]
  37. |No-spaces|
  38. Description
  39. -----------
  40. **convert** reads its standard input [or input files] and writes out
  41. the desired information to standard output. It can do a combination of
  42. nine tasks: (1) convert between binary and ASCII data tables, (2) paste
  43. corresponding records from multiple files horizontally into a single
  44. file, (3) extract a subset of the available columns, (4) only extract
  45. segments whose header record matches a text pattern search, (5) only
  46. list segment headers and no data records, (6) extract first and/or last
  47. data record for each segment, (7) reverse the order of items on output,
  48. (8) output only ranges of segment numbers, and (9) output only segments
  49. whose record count matches criteria. Input (and hence output) may have multiple
  50. sub-headers, and ASCII tables may have regular headers as well.
  51. Required Arguments
  52. ------------------
  53. None
  54. Optional Arguments
  55. ------------------
  56. .. |Add_intables| unicode:: 0x20 .. just an invisible code
  57. .. include:: explain_intables.rst_
  58. .. _-A:
  59. **-A**
  60. The records from the input files should be pasted horizontally, not
  61. appended vertically [Default]. All files must have the same number
  62. of segments and number of rows per segment. Note for binary input,
  63. all the files you want to paste must have the same number of columns
  64. (as set with **-bi**); ASCII tables can have different number of columns.
  65. .. _-C:
  66. **-C**\ [**+l**\ *min*][**+u**\ *max*][**+i**]
  67. Only output segments whose number of records matches your given criteria:
  68. Append **+l**\ *min* to ensure all segment must have at least *min* records
  69. to be written to output [0], and append **+u**\ *max* to ensure all segments
  70. must have at most *max* records to be written [inf]. You may append **+i**
  71. to invert the selection, i.e., only segments with record counts outside the
  72. given range will be output.
  73. .. _-D:
  74. **-D**\ [*template*\ [**+o**\ *orig*]]
  75. For multiple segment data, dump each segment to a separate output
  76. file [Default writes a multiple segment file to stdout]. Append a
  77. format template for the individual file names; this template
  78. **must** contain a C format specifier that can format an integer
  79. argument (the running segment number across all tables); this is
  80. usually %d but could be %08d which gives leading zeros, etc.
  81. [Default is gmtconvert_segment\_%d.{txt\|bin}, depending on
  82. **-bo**]. Append **+o**\ *orig* to start the numbering from *orig*
  83. instead of zero. Alternatively, give a template with
  84. two C format specifiers and we will supply the table number and the
  85. segment number within the table to build the file name.
  86. Append **+o**\ *torig*\ /*sorig* to start the numbering of tables
  87. from *torig* and numbering of segments within a table from *sorig*
  88. instead of zero. The **+o** modifier will be stripped off before
  89. the *template* is used.
  90. .. _-E:
  91. **-E**\ [**f**\|\ **l**\|\ **m**\|\ **M**\ *stride*]
  92. Only extract the first and last record for each segment of interest
  93. [Default extracts all records]. Optionally, append **f** or **l** to
  94. only extract the first or last record of each segment, respectively.
  95. Alternatively, append **m**\ *stride* to extract every *stride* records;
  96. use **M** to also include the last record.
  97. .. _-F:
  98. **-F**\ [**c**\|\ **n**\|\ **r**\|\ **v**][**a**\|\ **f**\|\ **s**\|\ **r**\|\ *refpoint*]
  99. Alter the way points are connected (by specifying a *scheme*) and data are grouped (by specifying a *method*).
  100. Append one of four line connection schemes:
  101. **c**\ : Form continuous line segments for each group [Default].
  102. **r**\ : Form line segments from a reference point reset for each group.
  103. **n**\ : Form networks of line segments between all points in each group.
  104. **v**\ : Form vector line segments suitable for :doc:`plot` **-Sv+s**.
  105. Optionally, append the one of four segmentation methods to define the group:
  106. **a**\ : Ignore all segment headers, i.e., let all points belong to a single group,
  107. and set group reference point to the very first point of the first file.
  108. **f**\ : Consider all data in each file to be a single separate group and
  109. reset the group reference point to the first point of each group.
  110. **s**\ : Segment headers are honored so each segment is a group; the group
  111. reference point is reset to the first point of each incoming segment [Default].
  112. **r**\ : Same as **s**, but the group reference point is reset after
  113. each record to the previous point (this method is only available with the **-Fr** scheme).
  114. Instead of the codes **a**\|\ **f**\|\ **s**\|\ **r** you may append
  115. the coordinates of a *refpoint* which will serve as a fixed external
  116. reference point for all groups.
  117. .. _-I:
  118. **-I**\ [**tsr**]
  119. Invert the order of items, i.e., output the items in reverse order,
  120. starting with the last and ending up with the first item [Default
  121. keeps original order]. Append up to three items that should be
  122. reversed: **t** will reverse the order of tables, **s** will reverse
  123. the order of segments within each table, and **r** will reverse the
  124. order of records within each segment [Default].
  125. .. _-L:
  126. **-L**
  127. Only output a listing of all segment header records and no data
  128. records (requires ASCII data).
  129. .. _-N:
  130. **-N**\ *col*\ [**+a**\|\ **d**]
  131. Numerically sort each segment based on values in column *col*.
  132. The data records will be sorted such that the chosen column will
  133. fall into ascending order [**+a**\ , which is Default]. Append **+d**
  134. to sort into descending order instead. The **-N** option can be
  135. combined with any other ordering scheme except **-F** (segmentation)
  136. and is applied at the end.
  137. .. _-Q:
  138. **-Q**\ [**~**]\ *selection*
  139. Only write segments whose number is included in *selection* and skip
  140. all others. Cannot be used with **-S**. The *selection* syntax is
  141. *range*\ [,\ *range*,...] where each *range* of items is either a single
  142. segment *number* or a range with stepped increments given via *start*\ [:*step*:]\ :*stop*
  143. (*step* is optional and defaults to 1). A leading **~** will
  144. invert the selection and write all segments but the ones listed. Instead
  145. of a list of ranges, use **+f**\ *file* to supply a file list with one *range* per line.
  146. .. _-S:
  147. **-S**\ [**~**]\ *"search string"* or **-S**\ [**~**]/\ *regexp*/[**i**]
  148. Only output those segments whose header record contains the
  149. specified text string. To reverse the search, i.e., to output
  150. segments whose headers do *not* contain the specified pattern, use
  151. **-S~**. Should your pattern happen to start with ~ you need to
  152. escape this character with a backslash [Default output all
  153. segments]. Cannot be used with **-Q**. For matching segments based
  154. on aspatial values (via OGR/GMT format), give the search string as
  155. *varname*\ =\ *value* and we will compare *value* against the value
  156. of *varname* for each segment. **Note**: If the features are polygons
  157. then a match of a particular polygon perimeter also means that any
  158. associated polygon holes will also be matched. For matching segment
  159. headers against extended regular expressions enclose the expression
  160. in slashes. Append **i** for case-insensitive matching.
  161. For a list of such patterns, give **+f**\ *file* with one pattern per line.
  162. To give a single pattern starting with +f, escape it with a backslash.
  163. .. _-T:
  164. **-T**\ [**h**\|\ **d**]
  165. Suppress the writing of certain records on output. Append **h** to
  166. suppress segment headers [Default] or **d** to suppress duplicate
  167. data records. Use **-Thd** to suppress both types of records.
  168. .. _-V:
  169. .. |Add_-V| unicode:: 0x20 .. just an invisible code
  170. .. include:: explain_-V.rst_
  171. .. _-W:
  172. **-W**\ [**+n**]
  173. Attempt to convert each word in the trailing text to a number and append
  174. such values to the numerical output columns. Text that cannot be converted
  175. (because they are not numbers) will appear as NaNs. Use modifier **+n** to
  176. exclude the columns with NaNs. **Note**: These columns are identified based on
  177. the first input record only.
  178. .. include:: explain_-aspatial.rst_
  179. .. |Add_-bi| unicode:: 0x20 .. just an invisible code
  180. .. include:: explain_-bi.rst_
  181. .. |Add_-bo| replace:: [Default is same as input].
  182. .. include:: explain_-bo.rst_
  183. .. |Add_-d| unicode:: 0x20 .. just an invisible code
  184. .. include:: explain_-d.rst_
  185. .. |Add_-e| unicode:: 0x20 .. just an invisible code
  186. .. include:: explain_-e.rst_
  187. .. |Add_-f| unicode:: 0x20 .. just an invisible code
  188. .. include:: explain_-f.rst_
  189. .. |Add_-g| unicode:: 0x20 .. just an invisible code
  190. .. include:: explain_-g.rst_
  191. .. |Add_-h| unicode:: 0x20 .. just an invisible code
  192. .. include:: explain_-h.rst_
  193. .. include:: explain_-icols.rst_
  194. .. include:: explain_-ocols.rst_
  195. .. include:: explain_-q.rst_
  196. .. include:: explain_-s.rst_
  197. .. include:: explain_colon.rst_
  198. .. include:: explain_help.rst_
  199. .. include:: explain_precision.rst_
  200. Examples
  201. --------
  202. .. include:: explain_example.rst_
  203. To convert the binary file test.b (single precision) with 4 columns to ASCII::
  204. gmt convert test.b -bi4f > test.dat
  205. To convert the multiple segment ASCII table test.txt to a double precision binary file::
  206. gmt convert test.txt -bo > test.b
  207. You have an ASCII table with 6 columns and you want to plot column 5 versus column 0. Try::
  208. gmt convert table.txt -o5,0 | gmt plot ...
  209. If the file instead is the binary file results.b which has 9
  210. single-precision values per record, we extract the last column and
  211. columns 4-6 and write ASCII with the command::
  212. gmt convert results.b -o8,4-6 -bi9s | gmt plot ...
  213. You want to plot the 2nd column of a 2-column file left.txt versus the
  214. first column of a file right.txt::
  215. gmt convert left.txt right.txt -A -o1,2 | gmt plot ...
  216. To extract all segments in the file big_file.txt whose headers contain
  217. the string "RIDGE AXIS", try::
  218. gmt convert big_file.txt -S"RIDGE AXIS" > subset.txt
  219. To invert the selection of segments whose headers begin with "profile "
  220. followed by an integer number and any letter between "g" and "l", try::
  221. gmt convert -S~"/^profile [0-9]+[g-l]$/"
  222. To reverse the order of segments in a file without reversing the order
  223. of records within each segment, try::
  224. gmt convert lots_of_segments.txt -Is > last_segment_first.txt
  225. To extract segments 20 to 40 in steps of 2, plus segment 0 in a file, try::
  226. gmt convert lots_of_segments.txt -Q0,20:2:40 > my_segments.txt
  227. To extract the attribute ELEVATION from an ogr gmt file like this::
  228. # @VGMT1.0 @GPOINT
  229. ...
  230. # @NELEVATION|DISPX|DISPY
  231. # @Tdouble|double|double
  232. # FEATURE_DATA
  233. # @D4.945000|-106500.00000000|-32700.00000000
  234. -9.36890245902635 39.367156766570389
  235. do::
  236. gmt convert file.gmt -a2=ELEVATION > xyz.dat
  237. or just::
  238. gmt convert file.gmt -aELEVATION > xyz.dat
  239. To connect all points in the file sensors.txt with the specified origin
  240. at 23.5/19, try::
  241. gmt convert sensors.txt -F23.5/19 > lines.txt
  242. To write all segments in the two files A.txt and B.txt to
  243. individual files named profile_005000.txt, profile_005001.txt, etc.,
  244. where we reset the origin of the sequential numbering from 0 to 5000, try::
  245. gmt convert A.txt B.txt -Dprofile_%6.6d.txt+o5000
  246. To only read rows 100-200 and 500-600 from file junk.txt, try::
  247. gmt convert junk.txt -q100-200,500-600 < subset.txt
  248. To get all rows except those bad ones between rows 1000-2000, try::
  249. gmt convert junk.txt -q~1000-2000 > good.txt
  250. See Also
  251. --------
  252. :doc:`gmt`,
  253. :doc:`gmtinfo`,
  254. :doc:`gmtselect`
Tip!

Press p or to see the previous file or, n or to see the next file

Comments

Loading...