gmtconvert - Convert, Paste, and/or Extract columns from data tables
gmtconvert [ table ] [ -A ] [ -C[+lmin][+umax][+i]] [ -D[template] ] [ -E[f|l|mstride] ] [ -L ] [ -F[c|n|r|v][refpoint] ] [ -I[tsr] ] [ -Q[~]selection] [ -S[~]“search string” | -S[~]/regexp/[i] ] [ -T ] [ -V[level] ] [ -a<flags> ] [ -b<binary> ] [ -d<nodata> ] [ -f<flags> ] [ -g<gaps> ] [ -h<headers> ] [ -i<flags> ] [ -o<flags> ] [ -s<flags> ] [ -:[i|o] ]
Note: No space is allowed between the option flag and the associated arguments.
gmtconvert reads its standard input [or input files] and writes out the desired information to standard output. It can do a combination of nine tasks: (1) convert between binary and ASCII data tables, (2) paste corresponding records from multiple files horizontally into a single file, (3) extract a subset of the available columns, (4) only extract segments whose header record matches a text pattern search, (5) only list segment headers and no data records, (6) extract first and/or last data record for each segment, (7) reverse the order of items on output, (8) output only ranges of segment numbers, and (9) output only segments whose record count matches criteria. Input (and hence output) may have multiple sub-headers, and ASCII tables may have regular headers as well.
None
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, whereas other values are formatted according to FORMAT_FLOAT_OUT. 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 FORMAT_FLOAT_OUT setting.
To convert the binary file test.b (single precision) with 4 columns to ASCII:
gmt convert test.b -bi4f > test.dat
To convert the multiple segment ASCII table test.d to a double precision binary file:
gmt convert test.d -bo > test.b
You have an ASCII table with 6 columns and you want to plot column 5 versus column 0. Try
gmt convert table.d -o5,0 | psxy ...
If the file instead is the binary file results.b which has 9 single-precision values per record, we extract the last column and columns 4-6 and write ASCII with the command
gmt convert results.b -o8,4-6 -bi9s | psxy ...
You want to plot the 2nd column of a 2-column file left.d versus the first column of a file right.d:
gmt convert left.d right.d -A -o1,2 | psxy ...
To extract all segments in the file big_file.d whose headers contain the string “RIDGE AXIS”, try
gmt convert big_file.d -S"RIDGE AXIS" > subset.d
To invert the selection of segments whose headers begin with “profile ” followed by an integer number and any letter between “g” and “l”, try
gmt convert -S~"/^profile [0-9]+[g-l]$/"
To reverse the order of segments in a file without reversing the order of records within each segment, try
gmt convert lots_of_segments.txt -Is > last_segment_first.txt
To extract segments 20 to 40 in steps of 2, plus segment 0 in a file, try
gmt convert lots_of_segments.txt -Q0,20:2:40 > my_segments.txt
To extract the attribute ELEVATION from an ogr gmt file like this
# @VGMT1.0 @GPOINT ... # @NELEVATION|DISPX|DISPY # @Tdouble|double|double # FEATURE_DATA # @D4.945000|-106500.00000000|-32700.00000000 -9.36890245902635 39.367156766570389
do
gmt convert file.gmt -a2=ELEVATION > xyz.dat
or just
gmt convert file.gmt -aELEVATION > xyz.dat
To connect all points in the file sensors.txt with the specified origin at 23.5/19, try
gmt convert sensors.txt -F23.5/19 > lines.txt