GMT Manpages
GMT Manpages
GMT Manpages
P. Wessel, W. H. F. Smith,
R. Scharroo, J. Luis, and F. Wobbe
Contents
Core modules
Supplementary modules
Index
1
331
473
ii
CHAPTER 1
Core modules
1.1 blockmean
blockmean - Block average (x,y,z) data tables by L2 norm
1.1.1 Synopsis
blockmean [ table ] -Iincrement -Rregion [ -C ] [ -E[p] ] [ -S[m|n|s|w] ] [ -V[level] ] [ -W[i|o][+s] ] [
-bbinary ] [ -dnodata ] [ -fflags ] [ -hheaders ] [ -iflags ] [ -oflags ] [ -r ] [ -:[i|o] ]
Note: No space is allowed between the option flag and the associated arguments.
1.1.2 Description
blockmean reads arbitrarily located (x,y,z) triples [or optionally weighted quadruples (x,y,z,w)] from
standard input [or table] and writes to standard output a mean position and value for every non-empty
block in a grid region defined by the -R and -I arguments. Either blockmean, blockmedian, or blockmode
should be used as a pre-processor before running surface to avoid aliasing short wavelengths. These
routines are also generally useful for decimating or averaging (x,y,z) data. You can modify the precision
of the output format by editing the FORMAT_FLOAT_OUT parameter in your gmt.conf file, or you may
choose binary input and/or output to avoid loss of precision.
The resulting increment value depends on whether you have selected a gridline-registered or pixelregistered grid; see App-file-formats for details. Note: if -Rgrdfile is used then the grid spacing
has already been initialized; use -I to override the values.
-R[unit]xmin/xmax/ymin/ymax[r] (more ...) Specify the region of interest.
1.1.6 Examples
To find 5 by 5 minute block mean values from the ASCII data in hawaii.xyg, run
gmt blockmean hawaii.xyg -R198/208/18/25 -I5m > hawaii_5x5.xyg
1.2 blockmedian
blockmedian - Block average (x,y,z) data tables by L1 norm
1.2.1 Synopsis
blockmedian [ table ] -Iincrement -Rregion [ -C ] [ -E[b] ] [ -Er|s[-] ] [ -Q ] [ -Tquantile ] [ -V[level] ]
[ -W[i|o][+s] ] [ -bbinary ] [ -dnodata ] [ -fflags ] [ -hheaders ] [ -iflags ] [ -oflags ] [ -r ] [ -:[i|o] ]
Note: No space is allowed between the option flag and the associated arguments.
1.2.2 Description
blockmedian reads arbitrarily located (x,y,z) triples [or optionally weighted quadruples (x,y,z,w)] from
standard input [or table] and writes to standard output a median position and value for every non-empty
block in a grid region defined by the -R and -I arguments. Either blockmean, blockmedian, or blockmode
should be used as a pre-processor before running surface to avoid aliasing short wavelengths. These
routines are also generally useful for decimating or averaging (x,y,z) data. You can modify the precision
of the output format by editing the FORMAT_FLOAT_OUT parameter in your gmt.conf file, or you may
choose binary input and/or output to avoid loss of precision.
and will be converted to the equivalent degrees longitude at the middle latitude of the region (the
conversion depends on PROJ_ELLIPSOID). If y_inc is given but set to 0 it will be reset equal to
x_inc; otherwise it will be converted to degrees latitude. All coordinates: If = is appended then the
corresponding max x (east) or y (north) may be slightly adjusted to fit exactly the given increment
[by default the increment may be adjusted slightly to fit the given domain]. Finally, instead of
giving an increment you may specify the number of nodes desired by appending + to the supplied
integer argument; the increment is then recalculated from the number of nodes and the domain.
The resulting increment value depends on whether you have selected a gridline-registered or pixelregistered grid; see App-file-formats for details. Note: if -Rgrdfile is used then the grid spacing
has already been initialized; use -I to override the values.
-R[unit]xmin/xmax/ymin/ymax[r] (more ...) Specify the region of interest.
1.2.6 Examples
To find 5 by 5 minute block medians from the double precision binary data in hawaii_b.xyg and output
an ASCII table, run
gmt blockmedian hawaii_b.xyg -R198/208/18/25 -I5m -bi3d > hawaii_5x5.xyg
To compute the shape of a data distribution per bin via a box-and-whisker diagram we need the 0%,
25%, 50%, 75%, and 100% quantiles. To do so on a global 5 by 5 degree basis from the ASCII table
depths.xyz and send output to an ASCII table, run
gmt blockmedian depths.xyz -Rg -I5 -Eb -r > depths_5x5.txt
1.3 blockmode
blockmode - Block average (x,y,z) data tables by mode estimation
1.3. blockmode
1.3.1 Synopsis
blockmode [ table ] -Iincrement -Rregion [ -C ] [ -D[width][+c][+a|+l|+h ] [ -Er|s[-] ] [ -Q ] [ -V[level]
] [ -W[i|o][+s] ] [ -bbinary ] [ -dnodata ] [ -fflags ] [ -hheaders ] [ -iflags ] [ -oflags ] [ -r ] [ -:[i|o] ]
Note: No space is allowed between the option flag and the associated arguments.
1.3.2 Description
blockmode reads arbitrarily located (x,y,z) triples [or optionally weighted quadruples (x,y,z,w)] from
standard input [or table] and writes to standard output mode estimates of position and value for every
non-empty block in a grid region defined by the -R and -I arguments. Either blockmean, blockmedian,
or blockmode should be used as a pre-processor before running surface to avoid aliasing short wavelengths. These routines are also generally useful for decimating or averaging (x,y,z) data. You can modify
the precision of the output format by editing the FORMAT_FLOAT_OUT parameter in your gmt.conf
file, or you may choose binary input and/or output to avoid loss of precision.
enforce bin centering (+c) and select the lowest mode (+l) if there are multiples. [Default mode is
normally the Least Median of Squares (LMS) statistic].
-E Provide Extended report which includes s (the L1 scale of the mode), l, the lowest value, and h, the
high value for each block. Output order becomes x,y,z,s,l,h[,w]. [Default outputs x,y,z[,w]. See -W
for w output.
-Er|s[-] Provide source id s or record number r output, i.e., append the source id or record number
associated with the modal value. If tied then report the record number of the higher of the two
values; append - to instead report the record number of the lower value. Note that both -E and
-Er[-] may be specified. For -Es we expect input records of the form x,y,z[,w],sid, where sid is an
unsigned integer source id.
-Q (Quicker) Finds mode z and mean (x,y) [Default finds mode x, mode y, mode z].
-V[level] (more ...) Select verbosity level [c].
-W[i|o][+s] Weighted modifier[s]. Unweighted input and output has 3 columns x,y,z; Weighted i/o has
4 columns x,y,z,w. Weights can be used in input to construct weighted mean values in blocks.
Weight sums can be reported in output for later combining several runs, etc. Use -W for weighted
i/o, -Wi for weighted input only, -Wo for weighted output only. [Default uses unweighted i/o]. If
your weights are actually uncertainties (sigma) then append +s and we compute weight = 1/sigma.
-bi[ncols][t] (more ...) Select native binary input. [Default is 3 (or 4 if -Wi is set)].
-bo[ncols][type] (more ...) Select native binary output. [Default is 3 (or 4 if -Wo is set)]. -E adds 3
additional columns.
-d[i|o]nodata (more ...) Replace input columns that equal nodata with NaN and do the reverse on output.
-f[i|o]colinfo (more ...) Specify data types of input and/or output columns.
-h[i|o][n][+c][+d][+rremark][+rtitle] (more ...) Skip or produce header record(s).
-icols[l][sscale][ooffset][,...] (more ...) Select input columns (0 is first column).
-ocols[,...] (more ...) Select output columns (0 is first column).
-r (more ...) Set pixel node registration [gridline]. Each block is the locus of points nearest the grid
value location. For example, with -R10/15/10/15 and -I1: with the -r option 10 <= (x,y) < 11 is
one of 25 blocks; without it 9.5 <= (x,y) < 10.5 is one of 36 blocks.
-:[i|o] (more ...) Swap 1st and 2nd column on input and/or output.
-^ or just - Print a short message about the syntax of the command, then exits (NOTE: on Windows use
just -).
-+ or just + Print an extensive usage (help) message, including the explanation of any module-specific
option (but not the GMT common options), then exits.
-? or no arguments Print a complete usage (help) message, including the explanation of options, then
exits.
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.
1.3.6 Examples
To find 5 by 5 minute block mode estimates from the double precision binary data in hawaii_b.xyg and
output an ASCII table, run:
gmt blockmode hawaii_b.xyg -R198/208/18/25 -I5m -bi3d > hawaii_5x5.xyg
To determine the most frequently occurring values per 5x5 block using histogram binning, with data
representing integer counts, try
gmt blockmode data.txt -R0/100/0/100 -I5 -r -C -D
1.4 filter1d
filter1d - Time domain filtering of 1-D data tables
1.4.1 Synopsis
filter1d [ table ] -Ftype<width>[mode][+h] [ -Dincrement ] [ -E ] [ -Iignore_val ] [ -Llack_width ] [
-Nt_col ] [ -Qq_factor ] [ -Ssymmetry_factor ] [ -Tt_min/t_max/t_inc[+] ] [ -V[level] ] [ -bbinary ] [
-dnodata ] [ -fflags ] [ -ggaps ] [ -hheaders ] [ -iflags ] [ -oflags ] [ -:[i|o] ]
Note: No space is allowed between the option flag and the associated arguments.
1.4.2 Description
filter1d is a general time domain filter for multiple column time series data. The user specifies which
column is the time (i.e., the independent variable). (See -N option below). The fastest operation occurs
when the input time series are equally spaced and have no gaps or outliers and the special options are
not needed. filter1d has options -L, -Q, and -S for unevenly sampled data with gaps.
-bo[ncols][type] (more ...) Select native binary output. [Default is same as input].
-d[i|o]nodata (more ...) Replace input columns that equal nodata with NaN and do the reverse on output.
-f[i|o]colinfo (more ...) Specify data types of input and/or output columns.
-g[a]x|y|d|X|Y|D|[col]z[+|-]gap[u] (more ...) Determine data gaps and line breaks.
-h[i|o][n][+c][+d][+rremark][+rtitle] (more ...) Skip or produce header record(s).
-icols[l][sscale][ooffset][,...] (more ...) Select input columns (0 is first column).
-ocols[,...] (more ...) Select output columns (0 is first column).
-:[i|o] (more ...) Swap 1st and 2nd column on input and/or output.
-^ or just - Print a short message about the syntax of the command, then exits (NOTE: on Windows use
just -).
-+ or just + Print an extensive usage (help) message, including the explanation of any module-specific
option (but not the GMT common options), then exits.
-? or no arguments Print a complete usage (help) message, including the explanation of options, then
exits.
1.4.6 Examples
To filter the data set in the file cruise.gmtd containing evenly spaced gravity, magnetics, topography, and
distance (in m) with a 10 km Gaussian filter, removing outliers, and output a filtered value every 2 km
between 0 and 100 km:
gmt filter1d cruise.gmtd -T0/1.0e5/2000 -FG10000 -N3 -V > filtered_cruise.gmtd
Data along track often have uneven sampling and gaps which we do not want to interpolate using sample1d. To find the median depth in a 50 km window every 25 km along the track of cruise v3312, stored
in v3312.dt, checking for gaps of 10km and asymmetry of 0.3:
gmt filter1d v3312.dt -FM50 -T0/100000/25 -L10 -S0.3 > v3312_filt.dt
10
1.5 fitcircle
fitcircle - find mean position and great [or small] circle fit to points on a sphere.
1.5.1 Synopsis
fitcircle [ table ] -Lnorm [ -Fflags ] [ -S[lat] ] [ -V[level] ] [ -bibinary ] [ -dinodata ] [ -fflags ] [ -ggaps
] [ -hheaders ] [ -iflags ] [ -oflags ] [ -:[i|o] ]
Note: No space is allowed between the option flag and the associated arguments.
1.5.2 Description
fitcircle reads lon,lat [or lat,lon] values from the first two columns on standard input [or table]. These
are converted to Cartesian three-vectors on the unit sphere. Then two locations are found: the mean of
the input positions, and the pole to the great circle which best fits the input positions. The user may
choose one or both of two possible solutions to this problem. The first is called -L1 and the second is
called -L2. When the data are closely grouped along a great circle both solutions are similar. If the data
have large dispersion, the pole to the great circle will be less well determined than the mean. Compare
both solutions as a qualitative check.
The -L1 solution is so called because it approximates the minimization of the sum of absolute values of
cosines of angular distances. This solution finds the mean position as the Fisher average of the data, and
the pole position as the Fisher average of the cross-products between the mean and the data. Averaging
cross-products gives weight to points in proportion to their distance from the mean, analogous to the
leverage of distant points in linear regression in the plane.
The -L2 solution is so called because it approximates the minimization of the sum of squares of cosines
of angular distances. It creates a 3 by 3 matrix of sums of squares of components of the data vectors.
The eigenvectors of this matrix give the mean and pole locations. This method may be more subject to
roundoff errors when there are thousands of data. The pole is given by the eigenvector corresponding to
the smallest eigenvalue; it is the least-well represented factor in the data and is not easily estimated by
either method.
1.5. fitcircle
11
-S[lat] Attempt to fit a small circle instead of a great circle. The pole will be constrained to lie on the
great circle connecting the pole of the best-fit great circle and the mean location of the data. Optionally append the desired fixed latitude of the small circle [Default will determine the latitude].
-V[level] (more ...) Select verbosity level [c].
-bi[ncols][t] (more ...) Select native binary input. [Default is 2 input columns].
-dinodata (more ...) Replace input columns that equal nodata with NaN.
-f[i|o]colinfo (more ...) Specify data types of input and/or output columns.
-g[a]x|y|d|X|Y|D|[col]z[+|-]gap[u] (more ...) Determine data gaps and line breaks.
-h[i|o][n][+c][+d][+rremark][+rtitle] (more ...) Skip or produce header record(s).
-icols[l][sscale][ooffset][,...] (more ...) Select input columns (0 is first column).
-ocols[,...] (more ...) Select output columns (0 is first column).
-:[i|o] (more ...) Swap 1st and 2nd column on input and/or output.
-^ or just - Print a short message about the syntax of the command, then exits (NOTE: on Windows use
just -).
-+ or just + Print an extensive usage (help) message, including the explanation of any module-specific
option (but not the GMT common options), then exits.
-? or no arguments Print a complete usage (help) message, including the explanation of options, then
exits.
1.5.6 Examples
Suppose you have lon,lat,grav data along a twisty ship track in the file ship.xyg. You want to project
this data onto a great circle and resample it in distance, in order to filter it or check its spectrum. Do the
following:
gmt fitcircle ship.xyg -L2
gmt project ship.xyg -Cox/oy -Tpx/py -S -Fpz | sample1d -S-100 -I1 > output.pg
Here, ox/oy is the lon/lat of the mean from fitcircle, and px/py is the lon/lat of the pole. The file output.pg
has distance, gravity data sampled every 1 km along the great circle which best fits ship.xyg
If you have lon, lat points in the file data.txt and wish to return the northern hemisphere great circle pole
location using the L2 norm, try
gmt fitcircle data.txt -L2 -Fn > pole.txt
12
1.6 gmt_shell_functions.sh
gmt_shell_functions.sh - Practical functions to be used in GMT Bourne Again shell scripts
1.6.1 Synopsis
gmt_init_tmpdir
gmt_remove_tmpdir
gmt_clean_up [prefix]
gmt_message message
gmt_abort message
gmt_get_nrecords file(s)
gmt_get_ndatarecords file(s)
gmt_get_nfields string
gmt_get_field string
gmt_get_region file(s) [options]
gmt_get_gridregion file [options]
gmt_get_map_width -R -J
gmt_get_map_height -R -J
gmt_set_psfile file
gmt_set_pdffile file
gmt_set_framename prefix framenumber
gmt_set_framenext framenumber
1.6.2 Description
gmt_shell_functions.sh provides a set of functions to Bourne (again) shell scripts in support of GMT.
The calling shell script should include the following line, before the functions can be used:
. gmt_shell_functions.sh
Once included in a shell script, gmt_shell_functions.sh allows GMT users to do some scripting more
easily than otherwise. The functions made available are:
gmt_init_tmpdir Creates a temporary directory in /tmp or (when defined) in the directory specified by
the environment variable TMPDIR. The name of the temporary directory is returned as environment variable GMT_TMPDIR. This function also causes GMT to run in isolation mode, i.e.,
all temporary files will be created in GMT_TMPDIR and the gmt.conf file will not be adjusted.
1.6. gmt_shell_functions.sh
13
gmt_remove_tmpdir Removes the temporary directory and unsets the GMT_TMPDIR environment
variable.
gmt_cleanup Remove all files and directories in which the current process number is part of the file
name. If the optional prefix is given then we also delete all files and directories that begins with
the given prefix.
gmt_message Send a message to standard error.
gmt_abort Send a message to standard error and exit the shell.
gmt_get_nrecords Returns the total number of lines in file(s)
gmt_get_ndatarecords Returns the total number of data records in file(s), i.e., not counting headers.
gmt_get_nfields Returns the number of fields or words in string
gmt_get_field Returns the given field in a string. Must pass string between double quotes to preserve it
as one item.
gmt_get_region Returns the region in the form w/e/s/n based on the data in table file(s). Optionally add
-I*dx*/dy to round off the answer.
gmt_get_gridregion Returns the region in the form w/e/s/n based on the header of a grid file. Optionally
add -I*dx*/dy to round off the answer.
gmt_get_map_width Expects the user to give the desired -R -J settings and returns the map width in
the current measurement unit.
gmt_get_map_height Expects the user to give the desired -R -J settings and returns the map height in
the current measurement unit.
gmt_set_psfile Create the output PostScript file name based on the base name of a given file (usually
the script name $0).
gmt_set_framename Returns a lexically ordered filename stem (i.e., no extension) given the file prefix
and the current frame number, using a width of 6 for the integer including leading zeros. Useful
when creating animations and lexically sorted filenames are required.
gmt_set_framenext Accepts the current frame integer counter and returns the next integer counter.
1.6.3 Notes
1. These functions only work in the Bourne shell (sh) and their derivatives (like ash, bash, ksh and zsh).
These functions do not work in the C shell (csh) or their derivatives (like tcsh), and cannot be used in
DOS batch scripts either.
2. gmt_shell_functions.sh were first introduced in GMT version 4.2.2 and have since been regularly
expanded with other practical scripting short-cuts. If you want to suggest other functions, please do so
by adding a New Issue request on gmt.soest.hawaii.edu.
14
1.7 gmt.conf
gmt.conf - Configuration for GMT
1.7.1 Description
The following is a list of the parameters that are user-definable in GMT. The parameter names are
always given in UPPER CASE. The parameter values are case-insensitive unless otherwise noted. The
system defaults are given in brackets [ for SI (and US) ]. Those marked * can be set on the command
line as well (the corresponding option is given in parentheses). Note that default distances and lengths
below are given in both cm or inch; the chosen default depends on your choice of default unit (see
PROJ_LENGTH_UNIT). You can explicitly specify the unit used for distances and lengths by appending
c (cm), i (inch), or p (points). When no unit is indicated the value will be assumed to be in the unit set by
PROJ_LENGTH_UNIT. Several parameters take only true or false. Finally, most of these parameters
can be changed on-the-fly via the --PARAMETER=VALUE option to any GMT program. However, a
few are static and are only read via the gmt.conf file; these are labeled (static).
prefix
COLOR_
DIR_
FONT_
FORMAT_
GMT_
IO_
MAP_
PROJ_
PS_
TIME_
COLOR_BACKGROUND Color used for the background of images (i.e., when z < lowest color table
entry) [black].
COLOR_FOREGROUND Color used for the foreground of images (i.e., when z > highest color table
entry) [white].
COLOR_HSV_MAX_S Maximum saturation (0-1) assigned for most positive intensity value [0.1].
COLOR_HSV_MIN_S Minimum saturation (0-1) assigned for most negative intensity value [1.0].
COLOR_HSV_MAX_V Maximum value (0-1) assigned for most positive intensity value [1.0].
COLOR_HSV_MIN_V Minimum value (0-1) assigned for most negative intensity value [0.3].
COLOR_MODEL Selects in which color space a CPT should be interpolated. By default, color interpolation takes place directly on the RGB values which can produce some unexpected hues,
whereas interpolation directly on the HSV values better preserves those hues. The choices are:
1.7. gmt.conf
15
none (default: use whatever the COLOR_MODEL setting in the CPT demands), rgb (force interpolation in RGB), hsv (force interpolation in HSV), cmyk (assumes colors are in CMYK but
interpolates in RGB).
COLOR_NAN Color used for the non-defined areas of images (i.e., where z == NaN) [127.5].
DIR_DATA Session data dir. Overrides the value of the environment variable $GMT_DATADIR (see
Directory parameters in the CookBook).
DIR_DCW Path to optional Digital Chart of the World polygon files.
DIR_GSHHG Path to GSHHG files. Defaults to $GMT_SHAREDIR/coast if empty.
FONT Sets the default for all fonts, except FONT_LOGO. This setting is not included in the gmt.conf
file.
FONT_ANNOT Sets both FONT_ANNOT_PRIMARY and FONT_ANNOT_SECONDARY to the
value specified. This setting is not included in the gmt.conf file.
FONT_ANNOT_PRIMARY Font used for primary annotations, etc. [12p,Helvetica,black]. When + is
prepended, scale fonts, offsets and tick-lengths relative to FONT_ANNOT_PRIMARY.
FONT_ANNOT_SECONDARY Font
[14p,Helvetica,black].
to
use
for
time
axis
secondary
annotations
1.7. gmt.conf
17
[%.12lg]. To give some columns a separate format, supply one or more comma-separated
cols:format specifications, where cols can be specific columns (e.g., 5 for 6th since 0 is the first)
or a range of columns (e.g., 3-7). The last specification without column information will override
the format for all other columns. Alternatively, you can list N space-separated formats and these
apply to the first N columns.
FORMAT_TIME_MAP Sets
both
FORMAT_TIME_PRIMARY_MAP
and
FORMAT_TIME_SECONDARY_MAP to the value specified. This setting is not included in
the gmt.conf file.
FORMAT_TIME_PRIMARY_MAP Controls how primary month-, week-, and weekday-names are
formatted. Choose among full, abbreviated, and character. If the leading f, a, or c are replaced
with F, A, and C the entire annotation will be in upper case [full].
FORMAT_TIME_SECONDARY_MAP Controls how secondary month-, week-, and weekdaynames are formatted. Choose among full, abbreviated, and character. If the leading f, a, or c
are replaced with F, A, and C the entire annotation will be in upper case [full].
FORMAT_TIME_STAMP Defines the format of the time information in the UNIX time stamp. This
format is parsed by the C function strftime, so that virtually any text can be used (even not
containing any time information) [%Y %b %d %H:%M:%S].
GMT_COMPATIBILITY Determines if this GMT version should be able to parse command-line options for a prior major release. Specify either 4 or 5. If 4 is set we will parse obsolete GMT 4
options and issue warnings; if 5 is set then parsing GMT 4 only syntax will result in errors [4].
GMT_EXPORT_TYPE This setting is only used by external interfaces and controls the data type used
for table entries. Choose from double, single, [u]long, [u]int, [u]short, and [u]char [double].
GMT_EXTRAPOLATE_VAL Determines what to do if extrapolating beyond the data domain.
Choose among NaN, extrap or extrapval,val (without quotes). In the first case return NaN
for any element of x that is outside range [Default]. Second case lets the selected algorithm compute the extrapolation values. Third case sets the extrapolation values to the constant value passed
in val (this value must off course be numeric).
GMT_CUSTOM_LIBS Comma-separated list of GMT-compliant shared libraries that extend the capability of GMT with additional custom modules [none]. Alternatively, provide a directory name,
that MUST end with a slash (or back slash), to use all shared libraries in that directory. On Windows, if the dir name is made up only of a single slash (/) search inside a subdirectory called
gmt_plugins of the directory that contains the gmt executable. See the API documentation for
how to build your own shared modules.
GMT_FFT Determines which Fast Fourier Transform (FFT) should be used among those that have
been configured during installation. Choose from auto (pick the most suitable for the task among
available algorithms), fftw[,planner_flag] (The Fastest Fourier Transform in the West), accelerate (Use the Accelerate Framework under OS X; Note, that the number of samples to be
processed must be a base 2 exponent), kiss, (Kiss FFT), brenner Brenner Legacy FFT [auto].
FFTW can learn how to optimally compute Fourier transforms on the current hardware and
OS by computing several FFTs and measuring their execution time. This so gained Wisdom
will be stored in and reloaded from the file fftw_wisdom_<hostname> in $GMT_USERDIR or,
if $GMT_USERDIR is not writable, in the current directory. To use this feature append planner_flag, which can be one of measure, patient, and exhaustive; see FFTW reference for details.
The default FFTW planner flag is estimate, i.e., pick a (probably sub-optimal) plan quickly. Note:
if you need a single transform of a given size only, the one-time cost of the smart planner becomes
significant. In that case, stick to the default planner, estimate, based on heuristics.
18
GMT_HISTORY Passes the history of past common command options via the gmt.history file. The
different values for this setting are: true, readonly, false, to either read and write to the gmt.history
file, only read, or not use the file at all [true].
GMT_INTERPOLANT Determines if linear (linear), Akimas spline (akima), natural cubic spline (cubic) or no interpolation (none) should be used for 1-D interpolations in various programs [akima].
GMT_LANGUAGE Language to use when plotting calendar and map items such as months and days,
map annotations and cardinal points. Select from:
CN1 Simplified Chinese
CN2 Traditional Chinese
DE German
DK Danish
EH Basque
ES Spanish
FI Finnish
FR French
GR Greek
HI Hawaiian
HU Hungarian
IE Irish
IL Hebrew
IS Icelandic
IT Italian
JP Japanese
KR Korean
NL Dutch
NO Norwegian
PL Polish
PT Portuguese
RU Russian
SE Swedish
SG Scottish Gaelic
TO Tongan
TR Turkish
UK British English
US US English
1.7. gmt.conf
19
If
your
language
is
not
supported,
please
examine
the
$GMT_SHAREDIR/localization/gmt_us.locale file and make a similar file. Please submit
it to the GMT Developers for official inclusion. Custom language files can be placed in directories
$GMT_SHAREDIR/localization or ~/.gmt. Note: Some of these languages may require you to
also change the PS_CHAR_ENCODING setting.
GMT_TRIANGULATE Determines if we use the Watson [Default] or Shewchuk algorithm (if configured during installation) for triangulation. Note that Shewchuk is required for operations involving Voronoi constructions.
GMT_VERBOSE (-V) Determines the level of verbosity used by GMT programs. Choose among 6
levels; each level adds to the verbosity of the lower levels: quiet, nnormal (errors and warnings),
compatibility warnings, verbose progress reports, long verbose progress reports, debugging messages [c].
IO_COL_SEPARATOR This setting determines what character will separate ASCII output data
columns written by GMT. Choose from tab, space, comma, and none [tab].
IO_GRIDFILE_FORMAT Default file format for grids, with optional scale, offset and invalid value,
written as ff /scale/offset/invalid. The 2-letter format indicator can be one of [abcegnrs][bsifd].
See grdconvert and Section grid-file-format of the GMT Technical Reference and Cookbook for
more information. The scale and offset modifiers may be left empty to select default values (scale
= 1, offset = 0), or you may specify a for auto-adjusting the scale and/or offset of packed integer
grids (=id/a is a shorthand for =id/a/a). When invalid is omitted the appropriate value for the given
format is used (NaN or largest negative). [nf].
IO_GRIDFILE_SHORTHAND If true, all grid file names are examined to see if they use the file
extension shorthand discussed in Section grid-file-format of the GMT Technical Reference and
Cookbook. If false, no filename expansion is done [false].
IO_HEADER (-h) Specifies whether input/output ASCII files have header record(s) or not [false].
IO_LONLAT_TOGGLE (-:) Set if the first two columns of input and output files contain (latitude,longitude) or (y,x) rather than the expected (longitude,latitude) or (x,y). false means we have
(x,y) both on input and output. true means both input and output should be (y,x). IN means only
input has (y,x), while OUT means only output should be (y,x). [false].
IO_N_HEADER_RECS Specifies how many header records to expect if -h is used [0]. Note: This will
skip the specified number of records regardless of what they are. Since any records starting with
# is automatically considered a header you will only specify a non-zero number in order to skip
headers that do not conform to that convention.
IO_NAN_RECORDS Determines what happens when input records containing NaNs for x or y (and
in some cases z) are read. Choose between skip, which will simply report how many bad records
were skipped, and pass [Default], which will pass these records on to the calling programs. For
most programs this will result in output records with NaNs as well, but some will interpret these
NaN records to indicate gaps in a series; programs may then use that information to detect segmentation (if applicable).
IO_NC4_CHUNK_SIZE Sets the default chunk size for the lat and lon dimension of the z variable.
Very large chunk sizes and sizes smaller than 128 should be avoided because they can lead to
unexpectedly bad performance. Note that a chunk of a single precision floating point variable
of size 2896x2896 completely fills the chunk cache of 32MiB. Specify the chunk size for each
dimension separated by a comma, or auto for optimally chosen chunk sizes in the range [128,256).
Setting IO_NC4_CHUNK_SIZE will produce netCDF version 4 files, which can only be read
20
with the netCDF 4 library, unless all dimensions are less than 128 or classic is specified for classic
netCDF. [auto]
IO_NC4_DEFLATION_LEVEL Sets the compression level for netCDF4 files upon output. Values
allowed are integers from 0 (no compression) to 9 (maximum compression). Enabling a low compression level can dramatically improve performance and reduce the size of certain data. While
higher compression levels further reduce the data size, they do so at the cost of extra processing
time. This parameter does not apply to classic netCDF files. [3]
IO_SEGMENT_BINARY Determines how binary data records with all values set to NaN are interpreted. Such records are considered to be encoded segment headers in binary files provided the
number of columns equals or exceeds the current setting of IO_SEGMENT_BINARY [2]. Specify
0 or off to deactivate the segment header determination.
IO_SEGMENT_MARKER This holds the character we expect to indicate a segment header in an incoming ASCII data or text table [>]. If this marker should be different for output then append another character for the output segment marker. The two characters must be separated by a comma.
Two marker characters have special meaning: B means blank line and will treat blank lines as
initiating a new segment, whereas N means NaN record and will treat records with all NaNs
as initiating a new segment. If you choose B or N for the output marker then the normal GMT
segment header is replaced by a blank or NaN record, respectively, and no segment header information is written. To use B or N as regular segment markers you must escape them with a leading
backslash.
MAP_ANNOT_MIN_ANGLE If the angle between the map boundary and the annotation baseline is
less than this minimum value (in degrees), the annotation is not plotted (this may occur for certain
oblique projections.) Give a value in the range [0,90]. [20]
MAP_ANNOT_MIN_SPACING If an annotation would be plotted less than this minimum distance
from its closest neighbor, the annotation is not plotted (this may occur for certain oblique projections.) [0p]
MAP_ANNOT_OBLIQUE This integer is a sum of 6 bit flags (most of which only are relevant for
oblique projections): If bit 1 is set (1), annotations will occur wherever a gridline crosses the
map boundaries, else longitudes will be annotated on the lower and upper boundaries only, and
latitudes will be annotated on the left and right boundaries only. If bit 2 is set (2), then longitude
annotations will be plotted horizontally. If bit 3 is set (4), then latitude annotations will be plotted
horizontally. If bit 4 is set (8), then oblique tick-marks are extended to give a projection equal
to the specified tick length. If bit 5 is set (16), tick-marks will be drawn normal to the border
regardless of gridline angle. If bit 6 is set (32), then latitude annotations will be plotted parallel to
the border. To set a combination of these, add up the values in parentheses. [1].
MAP_ANNOT_OFFSET Sets
both
MAP_ANNOT_OFFSET_PRIMARY
and
MAP_ANNOT_OFFSET_SECONDARY to the value specified. This setting is not included in
the gmt.conf file.
MAP_ANNOT_OFFSET_PRIMARY Distance from end of tick-mark to start of annotation [5p].
MAP_ANNOT_OFFSET_SECONDARY Distance from base of primary annotation to the top of the
secondary annotation [5p] (Only applies to time axes with both primary and secondary annotations).
MAP_ANNOT_ORTHO Determines which axes will get their annotations (for linear projections)
plotted orthogonally to the axes. Combine any w, e, s, n, z (uppercase allowed as well). [we]
(if nothing specified).
1.7. gmt.conf
21
MAP_POLAR_CAP Controls the appearance of gridlines near the poles for all azimuthal projections
and a few others in which the geographic poles are plotted as points (Lambert Conic, Oblique
Mercator, Hammer, Mollweide, Sinusoidal and van der Grinten). Specify either none (in which
case there is no special handling) or pc_lat/pc_dlon. In that case, normal gridlines are only drawn
between the latitudes -pc_lat/+*pc_lat*, and above those latitudes the gridlines are spaced at the
(presumably coarser) pc_dlon interval; the two domains are separated by a small circle drawn at
the pc_lat latitude [85/90]. Note for r-theta (polar) projection where r = 0 is at the center of the
plot the meaning of the cap is reversed, i.e., the default 85/90 will draw a r = 5 radius circle at the
center of the map with less frequent radial lines there.
MAP_SCALE_HEIGHT Sets the height (> 0) on the map of the map scale bars drawn by various
programs [5p].
MAP_TICK_LENGTH Sets
both
MAP_TICK_LENGTH_PRIMARY
and
MAP_TICK_LENGH_SECONDARY to the value specified. This setting is not included
in the gmt.conf file.
MAP_TICK_LENGTH_PRIMARY The length of a primary major/minor tick-marks [5p/2.5p]. If
only the first value is set, the second is assumed to be 50% of the first.
MAP_TICK_LENGTH_SECONDARY The length of a secondary major/minor tick-marks
[15p/3.75p]. If only the first value is set, the second is assumed to be 25% of the first.
MAP_TICK_PEN Sets
both
MAP_TICK_PEN_PRIMARY
and
MAP_TICK_PEN_SECONDARY to the value specified. This setting is not included in
the gmt.conf file.
MAP_TICK_PEN_PRIMARY Pen attributes to be used for primary tick-marks in dpi units or points
(append p) [thinner,black].
MAP_TICK_PEN_SECONDARY Pen attributes to be used for secondary tick-marks in dpi units or
points (append p) [thinner,black].
MAP_TITLE_OFFSET Distance from top of axis annotations (or axis label, if present) to base of plot
title [14p].
MAP_VECTOR_SHAPE Determines the shape of the head of a vector. Normally (i.e., for vector_shape = 0), the head will be triangular, but can be changed to an arrow (1) or an open V
(2). Intermediate settings give something in between. Negative values (up to -2) are allowed as
well [0].
PROJ_AUX_LATITUDE Only applies when geodesics are approximated by great circle distances on
an equivalent sphere. Select from authalic, geocentric, conformal, meridional, parametric, or none
[authalic]. When not none we convert any latitude used in the great circle calculation to the chosen
auxiliary latitude before doing the distance calculation. See also PROJ_MEAN_RADIUS.
PROJ_ELLIPSOID The (case sensitive) name of the ellipsoid used for the map projections [WGS-84].
Choose among:
23
25
26
A6 297 421
A7 210 297
A8 148 210
A9 105 148
A10 74 105
B0 2836 4008
B1 2004 2836
B2 1418 2004
B3 1002 1418
B4 709 1002
B5 501 709
archA 648 864
archB 864 1296
archC 1296 1728
archD 1728 2592
archE 2592 3456
flsa 612 936
halfletter 396 612
statement 396 612
note 540 720
letter 612 792
legal 612 1008
11x17 792 1224
tabloid 792 1224
ledger 1224 792
For a completely custom format (e.g., for large format plotters) you may also specify WxH, where
W and H are in points unless you append a unit to each dimension (c, i, m or p [Default]).
PS_MITER_LIMIT Sets the threshold angle in degrees (integer in range [0,180]) used for mitered
joins only. When the angle between joining line segments is smaller than the threshold the corner
will be bevelled instead of mitered. The default threshold is 35 degrees. Setting the threshold angle
to 0 implies the PostScript default of about 11 degrees. Setting the threshold angle to 180 causes
all joins to be beveled.
PS_PAGE_COLOR Sets the color of the imaging background, i.e., the paper [white].
PS_PAGE_ORIENTATION (* -P) Sets the orientation of the page. Choose portrait or landscape [landscape].
PS_SCALE_X Global x-scale (> 0) to apply to plot-coordinates before plotting. Normally used to
shrink the entire output down to fit a specific height/width [1.0].
1.7. gmt.conf
27
PS_SCALE_Y Global y-scale (> 0) to apply to plot-coordinates before plotting. Normally used to
shrink the entire output down to fit a specific height/width [1.0].
PS_TRANSPARENCY Sets the transparency mode to use when preparing PS for rendering to PDF.
Choose from Color, ColorBurn, ColorDodge, Darken, Difference, Exclusion, HardLight, Hue,
Lighten, Luminosity, Multiply, Normal, Overlay, Saturation, SoftLight, and Screen [Normal].
TIME_EPOCH Specifies the value of the calendar and clock at the origin (zero point) of relative time
units (see TIME_UNIT). It is a string of the form yyyy-mm-ddT[hh:mm:ss] (Gregorian) or yyyyWww-ddT[hh:mm:ss] (ISO) Default is 1970-01-01T00:00:00, the origin of the UNIX time epoch.
TIME_INTERVAL_FRACTION Determines if partial intervals at the start and end of an axis should
be annotated. If the range of the partial interval exceeds the specified fraction of the normal interval
stride we will place the annotation centered on the partial interval [0.5].
TIME_IS_INTERVAL Used when input calendar data should be truncated and adjusted to the middle
of the relevant interval. In the following discussion, the unit u can be one of these time units:
(y year, o month, u ISO week, d day, h hour, m minute, and s second). TIME_IS_INTERVAL
can have any of the following three values: (1) OFF [Default]. No adjustment, time is decoded
as given. (2) +nu. Activate interval adjustment for input by truncate to previous whole number
of n units and then center time on the following interval. (3) -nu. Same, but center time on the
previous interval. For example, with TIME_IS_INTERVAL = +1o, an input data string like 199912 will be interpreted to mean 1999-12-15T12:00:00.0 (exactly middle of December), while if
TIME_IS_INTERVAL = off then that date is interpreted to mean 1999-12-01T00:00:00.0 (start
of December) [off].
TIME_REPORT Controls if a time-stamp should be issued at start of all progress reports. Choose
among TIMER_CLOCK (absolute time stamp), TIMER_ELAPSED (time since start of session), or TIMER_NONE [Default].
TIME_SYSTEM Shorthand for a combination of TIME_EPOCH and TIME_UNIT, specifying
which time epoch the relative time refers to and what the units are. Choose from one of the preset
systems below (epoch and units are indicated):
JD -4713-11-25T12:00:00 d (Julian Date)
MJD 1858-11-17T00:00:00 d (Modified Julian Date)
J2000 2000-01-01T12:00:00 d (Astronomical time)
S1985 1985-01-01T00:00:00 s (Altimetric time)
UNIX 1970-01-01T00:00:00 s (UNIX time)
RD0001 0001-01-01T00:00:00 s
RATA 0000-12-31T00:00:00 d
This parameter is not stored in the gmt.conf file but is translated to the respective values of
TIME_EPOCH and TIME_UNIT.
TIME_UNIT Specifies the units of relative time data since epoch (see TIME_EPOCH). Choose y
(year - assumes all years are 365.2425 days), o (month - assumes all months are of equal length
y/12), d (day), h (hour), m (minute), or s (second) [s].
TIME_WEEK_START When weeks are indicated on time axes, this parameter determines the first
day of the week for Gregorian calendars. (The ISO weekly calendar always begins weeks with
Monday.) [Monday (or Sunday)].
28
TIME_Y2K_OFFSET_YEAR When 2-digit years are used to represent 4-digit years (see various
FORMAT_DATEs), TIME_Y2K_OFFSET_YEAR gives the first year in a 100-year sequence.
For example, if TIME_Y2K_OFFSET_YEAR is 1729, then numbers 29 through 99 correspond
to 1729 through 1799, while numbers 00 through 28 correspond to 1800 through 1828. [1950].
1.8 gmt
gmt - The Generic Mapping Tools data processing and display software package
1.8.1 Introduction
GMT is a collection of public-domain Unix tools that allows you to manipulate x,y and x,y,z data sets (filtering, trend fitting, gridding, projecting, etc.) and produce PostScript illustrations ranging from simple
x-y plots, via contour maps, to artificially illuminated surfaces and 3-D perspective views in black/white
or full color. Linear, log10, and power scaling is supported in addition to over 30 common map projections. The processing and display routines within GMT are completely general and will handle any (x,y)
or (x,y,z) data as input.
1.8.2 Synopsis
gmt is the main program that can start any of the modules:
gmt module module-options
where module is the name of a GMT module and the options are those that pertain to that particular
module. If no module is given then several other options are available:
--help List and description of GMT modules.
--show-cores Show number of available cores.
--show-bindir Show directory of executables and exit.
--show-datadir Show data directory/ies and exit.
--show-modules List module names on stdout and exit.
--show-plugindir Show plugin directory and exit.
--show-sharedir Show share directory and exit.
--version Print version and exit.
= Check if that module exist and if so the program will exit with status of 0; otherwise the status of exit
will be non-zero.
1.8. gmt
29
31
1.8.7 Description
These are all the common GMT options that remain the same for all GMT programs. No space between
the option flag and the associated arguments.
-B[p|s]parameters Set map Frame and Axes parameters. The Frame parameters are specified by
-B[axes][+b][+gfill][+n][+olon/lat][+ttitle]
where axes selects which axes to plot. By default, all 4 map boundaries (or plot axes) are plotted
(named W, E, S, N). To customize, append the codes for those you want (e.g., WSn). Upper
case means plot and annotate while lower case just plots the specified axes. If a 3-D basemap is
selected with -p and -Jz, append Z or z to control the appearance of the vertical axis. By default
a single vertical axes will be plotted at the most suitable map corner. Override the default by
appending any combination of corner ids 1234, where 1 represents the lower left corner and the
order goes counter-clockwise. Append +b to draw the outline of the 3-D cube defined by -R; this
modifier is also needed to display gridlines in the x-z, y-z planes. Note that for 3-D views the
title, if given, will be suppressed. You can paint the interior of the canvas with +gfill. Append +n
to have no frame and annotations at all [Default is controlled by the codes]. Optionally append
+oplon/plat to draw oblique gridlines about specified pole [regular gridlines]. Ignored if gridlines
are not requested (below) and disallowed for the oblique Mercator projection. To add a plot title
(+ttitle). The Frame setting is optional but can be invoked once to override the above defaults.
The Axes parameters are specified by
-B[p|s][x|y|z]intervals[+l|Llabel][+pprefix][+uunit]
but you may also split this into two separate invocations for clarity, i.e.,
-B[p|s][x|y|z][+llabel][+pprefix][+uunit]
-B[p|s][x|y|z]intervals
The first optional flag following -B selects p (rimary) [Default] or s (econdary) axes information
(mostly used for time axes annotations). The [x|y|z] flags specify which axes you are providing
information for. If none are given then we default to xy. If you wish to give different annotation
intervals or labels for the various axes then you must repeat the B option for each axis (If a 3D basemap is selected with -p and -Jz, use -Bz to give settings for the vertical axis.). To add a
1.8. gmt
33
label to an axis, just append +llabel (Cartesian projections only). Use +L to force a horizontal
label for y-axes (useful for very short labels). If the axis annotation should have a leading text
prefix (e.g., dollar sign for those plots of your net worth) you can append +pprefix. For geographic
maps the addition of degree symbols, etc. is automatic (and controlled by the GMT default setting
FORMAT_GEO_MAP). However, for other plots you can add specific units by adding +uunit. If
any of these text strings contain spaces or special UNIX characters you will need to enclose them
in quotes. The intervals specification is a concatenated string made up of substrings of the form
[a|f|g]stride[+-phase][u].
The leading a is used to specify the annotation and major tick spacing [Default], f for minor tick
spacing, and g for gridline spacing. stride is the desired stride interval. The optional phase shifts
the annotation interval by that amount (positive or negative). The optional unit indicates the unit
of the stride and can be any of
Y (year, plot with 4 digits)
y (year, plot with 2 digits)
O (month, plot using FORMAT_DATE_MAP)
o (month, plot with 2 digits)
U (ISO week, plot using FORMAT_DATE_MAP)
u (ISO week, plot using 2 digits)
r (Gregorian week, 7-day stride from start of week TIME_WEEK_START)
K (ISO weekday, plot name of day)
D (date, plot using FORMAT_DATE_MAP)
d (day, plot day of month 0-31 or year 1-366, via FORMAT_DATE_MAP)
R (day, same as d, aligned with TIME_WEEK_START)
H (hour, plot using FORMAT_CLOCK_MAP)
h (hour, plot with 2 digits)
M (minute, plot using FORMAT_CLOCK_MAP)
m (minute, plot with 2 digits)
S (second, plot using FORMAT_CLOCK_MAP)
s (second, plot with 2 digits).
Note for geographic axes m and s instead mean arc minutes and arc seconds. All entities that are
language-specific are under control by GMT_LANGUAGE. Alternatively, for linear maps, we can
omit stride, thus setting xinfo, yinfo, or zinfo to a plots annotations at automatically determined
intervals,
ag plots both annotations and grid lines with the same spacing,
afg adds suitable minor tick intervals,
g plots grid lines with the same interval as if -Bf was used.
For custom annotations and intervals, let intervals be given as cintfile, where intfile contains any
number of records with coord type [label]. Here, type is one or more letters from a|i, f, and g. For
34
a|i you must supply a label that will be plotted at the coord location. For non-geographical projections: Give negative scale (in -Jx) or axis length (in -JX) to change the direction of increasing
coordinates (i.e., to make the y-axis positive down). For log10 axes: Annotations can be specified
in one of three ways:
1. stride can be 1, 2, 3, or -n. Annotations will then occur at 1, 1-2-5, or 1-2-3-4-...-9, respectively; for -n we annotate every nt magnitude. This option can also be used for the frame
and grid intervals.
2. An l is appended to the tickinfo string. Then, log10 of the tick value is plotted at every integer
log10 value.
3. A p is appended to the tickinfo string. Then, annotations appear as 10 raised to log10 of the
tick value.
For power axes: Annotations can be specified in one of two ways:
1. stride sets the regular annotation interval.
2. A p is appended to the tickinfo string. Then, the annotation interval is expected to be in
transformed units, but the annotation value will be plotted as untransformed units. E.g., if
stride = 1 and power = 0.5 (i.e., sqrt), then equidistant annotations labeled 1-4-9... will
appear.
These GMT parameters can affect the appearance of the map boundary:
MAP_ANNOT_MIN_ANGLE, MAP_ANNOT_MIN_SPACING, FONT_ANNOT_PRIMARY,
FONT_ANNOT_SECONDARY,
MAP_ANNOT_OFFSET_PRIMARY,
MAP_ANNOT_OFFSET_SECONDARY,
MAP_ANNOT_ORTHO,
MAP_FRAME_AXES,
MAP_DEFAULT_PEN, MAP_FRAME_TYPE, FORMAT_GEO_MAP, MAP_FRAME_PEN,
MAP_FRAME_WIDTH, MAP_GRID_CROSS_SIZE_PRIMARY, MAP_GRID_PEN_PRIMARY,
MAP_GRID_CROSS_SIZE_SECONDARY, MAP_GRID_PEN_SECONDARY, FONT_TITLE,
FONT_LABEL, MAP_LINE_STEP, MAP_ANNOT_OBLIQUE, FORMAT_CLOCK_MAP, FORMAT_DATE_MAP, FORMAT_TIME_PRIMARY_MAP, FORMAT_TIME_SECONDARY_MAP,
GMT_LANGUAGE,
TIME_WEEK_START,
MAP_TICK_LENGTH_PRIMARY,
and
MAP_TICK_PEN_PRIMARY; see the gmt.conf man page for details.
-Jparameters
Select map projection. The following character determines the projection. If the character is upper case
then the argument(s) supplied as scale(s) is interpreted to be the map width (or axis lengths), else the
scale argument(s) is the map scale (see its definition for each projection). UNIT is cm, inch, or point, depending on the PROJ_LENGTH_UNIT setting in gmt.conf, but this can be overridden on the command
line by appending c, i, or p to the scale or width values. Append h, +, or - to the given width if you instead
want to set map height, the maximum dimension, or the minimum dimension, respectively [Default is w
for width]. In case the central meridian is an optional parameter and it is being omitted, then the center of
the longitude range given by the -R option is used. The default standard parallel is the equator. The ellipsoid used in the map projections is user-definable by editing the gmt.conf file in your home directory. 73
commonly used ellipsoids and spheroids are currently supported, and users may also specify their own
custom ellipsoid parameters [Default is WGS-84]. Several GMT parameters can affect the projection:
PROJ_ELLIPSOID, GMT_INTERPOLANT, PROJ_SCALE_FACTOR, and PROJ_LENGTH_UNIT; see
the gmt.conf man page for details. Choose one of the following projections (The E or C after projection
names stands for Equal-Area and Conformal, respectively):
CYLINDRICAL PROJECTIONS:
-Jclon0/lat0/scale or -JClon0/lat0/width (Cassini).
1.8. gmt
35
Give the central meridian lon0, central parallel lat0 (optional), and scale (1:xxxx
or UNIT/degree).
-Juzone/scale or -JUzone/width (UTM - Universal Transverse Mercator [C]).
Give the UTM zone (A,B,1-60[C-X],Y,Z)) and scale (1:xxxx or UNIT/degree).
Zones: If C-X not given, prepend - or + to enforce southern or northern hemisphere conventions [northern if south > 0].
-Jy[lon0/ [lat0/ ]]scale or -JY[lon0/ [lat0/ ]]width (Cylindrical Equal-Area [E]).
Give the central meridian lon0 (optional), standard parallel lat0 (optional), and
scale (1:xxxx or UNIT/degree). The standard parallel is typically one of these
(but can be any value):
50 - Balthasart
45 - Gall-Peters
37.0666 - Caster
37.4 - Trystan Edwards
37.5 - Hobo-Dyer
30 - Behrman
0 - Lambert (default)
CONIC PROJECTIONS:
-Jblon0/lat0/lat1/lat2/scale or -JBlon0/lat0/lat1/lat2/width (Albers [E]). Give projection
center lon0/lat0, two standard parallels lat1/lat2, and scale (1:xxxx or UNIT/degree).
-Jdlon0/lat0/lat1/lat2/scale or -JDlon0/lat0/lat1/lat2/width (Conic Equidistant) Give
projection center lon0/lat0, two standard parallels lat1/lat2, and scale (1:xxxx or
UNIT/degree).
-Jllon0/lat0/lat1/lat2/scale or -JLlon0/lat0/lat1/lat2/width (Lambert [C]) Give
origin lon0/lat0, two standard parallels lat1/lat2, and scale along these (1:xxxx or
UNIT/degree).
-Jpoly/[lon0/[lat0/]]scale or -JPoly/[lon0/[lat0/]]width ((American) Polyconic). Give
the central meridian lon0 (optional), reference parallel lat0 (optional, default =
equator), and scale along central meridian (1:xxxx or UNIT/degree).
AZIMUTHAL PROJECTIONS:
Except for polar aspects, -Rw/e/s/n will be reset to -Rg. Use -R<...>r for smaller regions.
-Jalon0/lat0[/horizon]/scale or -JAlon0/lat0[/horizon]/width (Lambert [E]). lon0/lat0
specifies the projection center. horizon specifies the max distance from projection
center (in degrees, <= 180, default 90). Give scale as 1:xxxx or radius/lat, where
radius is distance in UNIT from origin to the oblique latitude lat.
-Jelon0/lat0[/horizon]/scale or -JElon0/lat0[/horizon]/width (Azimuthal Equidistant).
lon0/lat0 specifies the projection center. horizon specifies the max distance from
projection center (in degrees, <= 180, default 180). Give scale as 1:xxxx or radius/lat,
where radius is distance in UNIT from origin to the oblique latitude lat.
-Jflon0/lat0[/horizon]/scale or -JFlon0/lat0[/horizon]/width (Gnomonic). lon0/lat0
specifies the projection center. horizon specifies the max distance from projection
1.8. gmt
37
center (in degrees, < 90, default 60). Give scale as 1:xxxx or radius/lat, where radius
is distance in UNIT from origin to the oblique latitude lat.
-Jglon0/lat0[/horizon]/scale or -JGlon0/lat0[/horizon]/width (Orthographic). lon0/lat0
specifies the projection center. horizon specifies the max distance from projection
center (in degrees, <= 90, default 90). Give scale as 1:xxxx or radius/lat, where radius
is distance in UNIT from origin to the oblique latitude lat.
-Jglon0/lat0/altitude/azimuth/tilt/twist/Width/Height/scale or -JGlon0/lat0/altitude/azimuth/tilt/twist/Width/Hei
lon0/lat0 specifies the projection center. altitude is the height (in km) of the viewpoint
above local sea level. If altitude is less than 10, then it is the distance from the center
of the earth to the viewpoint in earth radii. If altitude has a suffix r then it is the radius
from the center of the earth in kilometers. azimuth is measured to the east of north
of view. tilt is the upward tilt of the plane of projection. If tilt is negative, then the
viewpoint is centered on the horizon. Further, specify the clockwise twist, Width, and
Height of the viewpoint in degrees. Give scale as 1:xxxx or radius/lat, where radius
is distance in UNIT from origin to the oblique latitude lat.
-Jslon0/lat0[/horizon]/scale or -JSlon0/lat0[/horizon]/width (General Stereographic [C]).
lon0/lat0 specifies the projection center. horizon specifies the max distance from
projection center (in degrees, < 180, default 90). Give scale as 1:xxxx (true at pole) or
lat0/1:xxxx (true at standard parallel lat) or radius/lat (radius in UNIT from origin to
the oblique latitude lat). Note if 1:xxxx is used then to specify horizon you must also
specify the lat as +-90 to avoid ambiguity.
MISCELLANEOUS PROJECTIONS:
-Jh[lon0/]scale or -JH[lon0/]width (Hammer [E]). Give the central meridian lon0 (optional) and scale along equator (1:xxxx or UNIT/degree).
-Ji[lon0/]scale or -JI[lon0/]width (Sinusoidal [E]). Give the central meridian lon0 (optional) and scale along equator (1:xxxx or UNIT/degree).
-Jkf[lon0/]scale or -JKf[lon0/]width (Eckert IV) [E]). Give the central meridian lon0
(optional) and scale along equator (1:xxxx or UNIT/degree).
-Jk[s][lon0/]scale or -JK[s][lon0/]width (Eckert VI) [E]). Give the central meridian lon0
(optional) and scale along equator (1:xxxx or UNIT/degree).
-Jn[lon0/]scale or -JN[lon0/]width (Robinson). Give the central meridian lon0 (optional)
and scale along equator (1:xxxx or UNIT/degree).
-Jr[lon0/]scale -JR[lon0/]width (Winkel Tripel). Give the central meridian lon0 (optional) and scale along equator (1:xxxx or UNIT/degree).
-Jv[lon0/]scale or -JV[lon0/]width (Van der Grinten). Give the central meridian lon0
(optional) and scale along equator (1:xxxx or UNIT/degree).
-Jw[lon0/]scale or -JW[lon0/]width (Mollweide [E]). Give the central meridian lon0 (optional) and scale along equator (1:xxxx or UNIT/degree).
NON-GEOGRAPHICAL PROJECTIONS:
-Jp[a]scale[/origin][r|z] or -JP[a]width[/origin][r|z] (Polar coordinates (theta,r))
Optionally insert a after -Jp [ or -JP] for azimuths CW from North instead of directions
CCW from East [Default]. Optionally append /origin in degrees to indicate an angular offset
[0]). Finally, append r if r is elevations in degrees (requires s >= 0 and n <= 90) or z if you
want to annotate depth rather than radius [Default]. Give scale in UNIT/r-unit.
38
1.8. gmt
39
type and positions must be exactly as indicated (however, input, output and plot formats are customizable; see gmt.conf). You can also use Cartesian projected coordinates compatible with the
chosen projection. Give them with a leading length unit, (e.g., -Rk-200/200/-300/300 for a 400 by
600 km rectangular area centered on the projection center (0, 0). These coordinates are internally
converted to the corresponding geographic (longitude, latitude) coordinates for the lower left and
upper right corners. This form is convenient when you want to specify a region directly in the
projected units (e.g., UTM meters).
In case of perspective view p, a z-range (zmin, zmax) can be appended to indicate the third dimension.
This needs to be done only when using the Jz option, not when using only the p option. In the latter case
a perspective view of the plane is plotted, with no third dimension.
-U[just/dx/dy/][c|label] Draw Unix System time stamp on plot. By adding just/dx/dy/, the user may
specify the justification of the stamp and where the stamp should fall on the page relative to lower
left corner of the plot. For example, BL/0/0 will align the lower left corner of the time stamp with
the lower left corner of the plot. Optionally, append a label, or c (which will plot the command
string.). The GMT parameters MAP_LOGO, MAP_LOGO_POS, and FORMAT_TIME_STAMP
can affect the appearance; see the gmt.conf man page for details. The time string will be in the
locale set by the environment variable TZ (generally local time).
-V[level] Select verbose mode, which will send progress reports to stderr. Choose among 6 levels of
verbosity; each level adds mode messages: q - Complete silence, not even fatal error messages are
produced. n - Normal verbosity: produce only fatal error messages. c - Produce also compatibility
warnings (same as when -V is omitted). v - Produce also warnings and progress messages (same
as -V only). l - Produce also detailed progress messages. d - Produce also debugging messages.
-X[a|c|f|r][x-shift[u]]
-Y[a|c|f|r][y-shift[u]] Shift plot origin relative to the current origin by (x-shift,y-shift) and optionally
append the length unit (c, i, or p). You can prepend a to shift the origin back to the original
position after plotting, prepend c to center the plot on the center of the paper (optionally add
shift), prepend f to shift the origin relative to the fixed lower left corner of the page, or prepend
r [Default] to move the origin relative to its current location. If -O is used then the default (xshift,y-shift) is (r0), otherwise it is (r1i). When -X or -Y are used without any further arguments,
the values from the last use of that option in a previous GMT command will be used.
-a[col=]name[...] Control how aspatial data are handled in GMT during input and output. Reading
OGR/GMT-formatted files: To assign certain aspatial data items to GMT data columns, give one
or more comma-separated associations col=name, where name is the name of an aspatial attribute
field in a OGR/GMT file and whose value we wish to as data input for column col. In addition,
to assign an aspatial value to non-column data, you may specify col as D for distance, G for
fill, I for ID, L for label, T for text, W for pen, and Z for value [e.g., used to look-up color
via a CPT]. If you skip the leading col= in the argument then we supply (and automatically
increment) a column value starting at 2. Writing OGR/GMT-formatted files: Give one or more
comma-separated associations col=name[:type], To write OGR/GMT-formatted files, give one or
more comma-separated associations col=name[:type], with an optional data type from DOUBLE,
FLOAT, INTEGER, CHAR, STRING, DATETIME, or LOGICAL [DOUBLE]. To extract information from GMT multisegment headers encoded in the -Ddistance, -Gfill, -IID, -Llabel, -Ttext,
-Wpen, or -Zvalue settings, specify COL as D, G, I, L, T, W or Z, respectively; type will be
set automatically. Finally, you must append +ggeometry, where geometry is either POINT, LINE,
or POLY. Optionally, prepend M for multi-versions of these geometries. To force the clipping of
features crossing the Dateline, use upper-case +G instead. See GMT Appendix Q for details of
the OGR/GMT file format.
-bi[ncols][type][w][+L|+B] Select native binary input. Here, ncols is the number of data columns of
40
given type, which must be one of c (int8_t, aka char), u (uint8_t, aka unsigned char), h (int16_t,
2-byte signed int), H (uint16_t, 2-byte unsigned int), i (int32_t, 4-byte signed int), I ((capital i)
uint32_t, 4-byte unsigned int), l ((lower case el) int64_t, 8-byte signed int), L (uint64_t, 8-byte
unsigned int), f (4-byte single-precision float), and d (8-byte double-precision float). In addition,
use x to skip ncols bytes anywhere in the record. For records with mixed types, simply append additional comma-separated combinations of ncolst. Append w to any item to force byte-swapping.
Alternatively, append +L|B to indicate that the entire data file should be read as little- or bigendian, respectively. The cumulative number of ncols may exceed the columns actually needed
by the program. If ncols is not specified we assume that type applies to all columns and that ncols
is implied by the expectation of the program. If the input file is netCDF, no -b is needed; simply
append ?var1/var2/... to the filename to specify the variables to be read.
-bo[ncols][type][w][+L|+B] Select native binary output. Here, ncols is the actual number of data
columns of type t, which must be one of c, u, h, H, i, I (capital i), l (lower case elle), L, f, and
d (see -bi). For a mixed-type output record, append additional comma-separated combinations of
ncols/t. Append w to any item to force byte-swapping or +L|B for byte-swapping of the entire
record. If ncols is not specified we assume that t applies to all columns and that ncols is implied
by the default output of the program. Note: NetCDF file output is not supported.
-ccopies Specify number of plot copies. [Default is 1]. When used without argument, use the same
number of copies and specified in the last -c in a previous GMT command.
-d[i|o]nodata Control how user-coded missing z data values are translated to official NaN values in
GMT. For input data we replace any value that equals nodata with NaN. For output data we
replace any NaN with the chosen nodata value. Use -di or -do to only affect input or output.
-dinodata Examine all input columns and if any item equals nodata we interpret this value as a missing
data item and substitute the value NaN.
-donodata Examine all output columns and if any item equals NAN we substitute it with the chosen
missing data value nodata.
-f[i|o]colinfo Specify the data types of input and/or output columns (time or geographical data). Specify
i or o to make this apply only to input or output [Default applies to both]. Give one or more
columns (or column ranges) separated by commas, or use -f multiple times (column ranges must
be given in the format start[:inc ]:stop, where inc defaults to 1 if not specified). Append T (absolute
calendar time), t (relative time in chosen TIME_UNIT since TIME_EPOCH), x (longitude), y
(latitude), p[unit] (projected x,y map coordinates in given unit [meter]) or f (floating point) to each
column or column range item. Shorthand -f[i|o]g means -f[i|o]0x,1y (geographic coordinates).
-g[a]x|y|d|X|Y|D|[col]z[+|-]gap[u] Examine the spacing between consecutive data points in order to
impose breaks in the line. Append x|X or y|Y to define a gap when there is a large enough change
in the x or y coordinates, respectively, or d|D for distance gaps; use upper case to calculate gaps
from projected coordinates. For gap-testing on other columns use [col]z; if col is not prepended
the it defaults to 2 (i.e., 3rd column). Append [+|-]gap and optionally a unit u. Regarding optional
signs: -ve means previous minus current column value must exceed gap to be a gap, +ve means
current minus previous column value must exceed gap, and no sign means the absolute value of
the difference must exceed gap. For geographic data (x|y|d), the unit u may be arc degree, minute,
or second, or meter [Default], foot, kilometer, Mile, nautical mile, or survey foot. For projected
data (X|Y|D), choose from inch, centimeter, or point [Default unit set by PROJ_LENGTH_UNIT].
Note: For x|y|z with time data the unit is instead controlled by TIME_UNIT. Repeat the option to
specify multiple criteria, of which any can be met to produce a line break. Issue an additional -ga
to indicate that all criteria must be met instead.
-h[i|o][n][+c][+d][+rremark][+ttitle] Input file(s) has header record(s). If used, the default number of
1.8. gmt
41
header records is IO_N_HEADER_RECS [1]. Use -hi if only input data should have header records
[Default will write out header records if the input data have them]. Blank lines and lines starting
with # are always skipped. For output you may request additional headers to be written via the
option modifiers, and use +d to remove existing header records. Append +c to issue a header
comment with column names to the output [none]. Append +r to add a remark comment to the
output [none]. Append +t to add a title comment to the output [none]. These optional strings may
contain n to indicate line-breaks). If used with native binary data we interpret n to instead mean
the number of bytes to skip on input or pad on output.
-icols[l][sscale][ooffset][,...] Select specific data columns for input, in arbitrary order. Columns not
listed will be skipped. Give individual columns (or column ranges in the format start[:inc ]:stop,
where inc defaults to 1 if not specified) separated by commas [Default reads all columns in order,
starting with the first column (0)]. Columns may not be repeated. To each column, optionally add
any of the following, in this order: l takes the log10 of the input values first; sscale, subsequently
multiplies by a given scale factor; ooffset, finally adds a given offset.
-n[b|c|l|n][+a][+bBC][+c][+tthreshold] Select grid interpolation mode by adding b for B-spline
smoothing, c for bicubic interpolation, l for bilinear interpolation, or n for nearest-neighbor value
(for example to plot categorical data). Optionally, append +a to switch off antialiasing (where
supported). Append +bBC to override the boundary conditions used, adding g for geographic, p
for periodic, or n for natural boundary conditions. For the latter two you may append x or y to
specify just one direction, otherwise both are assumed. Append +c to clip the interpolated grid to
input z-min/max [Default may exceed limits]. Append +tthreshold to control how close to nodes
with NaNs the interpolation will go. A threshold of 1.0 requires all (4 or 16) nodes involved in
interpolation to be non-NaN. 0.5 will interpolate about half way from a non-NaN value; 0.1 will
go about 90% of the way, etc. [Default is bicubic interpolation with antialiasing and a threshold
of 0.5, using geographic (if grid is known to be geographic) or natural boundary conditions].
-ocols[,...] Select specific data columns for output, in arbitrary order. Columns not listed will be skipped.
Give columns (or column ranges in the format start[:inc ]:stop, where inc defaults to 1 if not
specified) separated by commas. Columns may be repeated. [Default writes all columns in order].
-p[x|y|z]azim/elev[/zlevel][+wlon0/lat0[/z0]][+vx0/y0] Selects perspective view and sets the azimuth
and elevation of the viewpoint [180/90]. When -p is used in consort with -Jz or -JZ, a third value
can be appended which indicates at which z-level all 2D material, like the plot frame, is plotted
(in perspective). [Default is at the bottom of the z-axis]. Use -px or -py to plot against the wall x
= level or y = level (default is on the horizontal plane, which is the same as using -pz). For frames
used for animation, you may want to append + to fix the center of your data domain (or specify
a particular world coordinate point with +wlon0/lat[/z]) which will project to the center of your
page size (or specify the coordinates of the projected view point with +vx0/y0. When -p is used
without any further arguments, the values from the last use of -p in a previous GMT command
will be used.
-r Force pixel node registration [Default is gridline registration]. (Node registrations are defined in Section grid-registration of the GMT Technical Reference and Cookbook.)
-s[cols][a|r] Suppress output for records whose z-value equals NaN [Default outputs all records]. Append a to skip records where at least one field equal NaN. Append r to reverse the suppression,
i.e., only output the records whose z-value equals NaN. Alternatively, indicate a comma-separated
list of all columns or column ranges to consider for this NaN test (Column ranges must be given
in the format start[:inc ]:stop, where inc defaults to 1 if not specified).
-t[transp] Set PDF transparency level for an overlay, in 0-100 percent range. [Default is 0, i.e., opaque].
-x[[-]n] Limit the number of cores to be used in any OpenMP-enabled multi-threaded algorithms. By
42
default we try to use all available cores. Append n to only use n cores (if too large it will be
truncated to the maximum cores available). Finally, give a negative n to select (all - n) cores (or at
least 1 if n equals or exceeds all). The *-x** option is only available to GMT modules compiled
with OpenMP support.
-:[i|o] Swap 1st and 2nd column on input and/or output [Default is no swapping]. Append i to select
input only or o to select output only. [Default affects both]. This option is typically used to handle
(latitude, longitude) files; see also -icols[l][sscale][ooffset][,...].
-^ or just - Print a short message about the syntax of the command, then exits (NOTE: on Windows use
just -).
-+ or just + Print an extensive usage (help) message, including the explanation of any module-specific
option (but not the GMT common options), then exits.
-? or no arguments Print a complete usage (help) message, including the explanation of options, then
exits.
Specifying Color
color The color of lines, areas and patterns can be specified by a valid color name; by a gray shade (in
the range 0-255); by a decimal color code (r/g/b, each in range 0-255; h-s-v, ranges 0-360, 0-1,
0-1; or c/m/y/k, each in range 0-1); or by a hexadecimal color code (#rrggbb, as used in HTML).
For PDF transparency, append @transparency in the 0-100 percent range [0 or opaque]. See the
gmtcolors for more information and a full list of color names. See GMT Cookbook & Technical
Reference Chapter 4 for more information.
Specifying Fill
fill The attribute fill specifies the solid shade or solid color (see Specifying Color above) or the pattern used for filling polygons. Patterns are specified as pdpi/pattern, where pattern gives the
number of the built-in pattern (1-90) or the name of a Sun 1-, 8-, or 24-bit raster file. The dpi
sets the resolution of the image. For 1-bit rasters: use Pdpi/pattern for inverse video, or append
:Fcolor[B[color]] to specify fore- and background colors (use color = - for transparency). See
GMT Cookbook & Technical Reference Appendix E for information on individual patterns.
Specifying Fonts
font The attributes of text fonts as defined by font is a comma delimited list of size, fonttype and fill,
each of which is optional. size is the font size (usually in points) but c or i can be added to indicate
other units. fonttype is the name (case sensitive!) of the font or its equivalent numerical ID (e.g.,
Helvetica-Bold or 1). fill specifies the gray shade, color or pattern of the text (see Specifying Fill
above). Optionally, you may append =pen to the fill value in order to draw a text outline. If you
want to avoid that the outline partially obscures the text, append append =~pen instead; in that
case only half the linewidth is plotted on the outside of the font only. If an outline is requested,
you may optionally skip the text fill by setting it to -, in which case the full pen width is always
used. If any of the font attributes is omitted their default or previous setting will be retained.
The 35 available fonts are:
0. Helvetica
1. Helvetica-Bold
1.8. gmt
43
2. Helvetica-Oblique
3. Helvetica-BoldOblique
4. Times-Roman
5. Times-Bold
6. Times-Italic
7. Times-BoldItalic
8. Courier
9. Courier-Bold
10. Courier-Oblique
11. Courier-BoldOblique
12. Symbol
13. AvantGarde-Book
14. AvantGarde-BookOblique
15. AvantGarde-Demi
16. AvantGarde-DemiOblique
17. Bookman-Demi
18. Bookman-DemiItalic
19. Bookman-Light
20. Bookman-LightItalic
21. Helvetica-Narrow
22. Helvetica-Narrow-Bold
23. Helvetica-Narrow-Oblique
24. Helvetica-Narrow-BoldOblique
25. NewCenturySchlbk-Roman
26. NewCenturySchlbk-Italic
27. NewCenturySchlbk-Bold
28. NewCenturySchlbk-BoldItalic
29. Palatino-Roman
30. Palatino-Italic
31. Palatino-Bold
32. Palatino-BoldItalic
33. ZapfChancery-MediumItalic
34. ZapfDingbats
44
Specifying Pens
pen The attributes of lines and symbol outlines as defined by pen is a comma-delimited list of width,
color and style, each of which is optional. width can be indicated as a measure (in points (this is the
default), centimeters, or inches) or as faint, default, thin[ner|nest], thick[er|est], fat[ter|test], or
obese. color specifies a gray shade or color (see Specifying Color above). style is a combination
of dashes - and dots .. If any of the attributes is omitted their default or previous setting will be
retained. See GMT Cookbook & Technical Reference Chapter 4 for more information.
1.8. gmt
45
1.9 gmt2kml
gmt2kml - Convert GMT data tables to KML files for Google Earth
1.9.1 Synopsis
gmt2kml [ table ] [ -Aa|g|s[alt|xscale] ] [ -Ccpt ] [ -Ddescriptfile ] [ -E[altitude] ] [ -Fe|s|t|l|p ] [ -Gf|n|fill ] [ -Iicon ] [ -K] [ -Lcol1:name1,col2:name2,... ] [ -N[+|*name_template*|name] ] [ -O] [ -Ra|w/e/s/n
] [ -Sc|nscale] ] [ -Ttitle[/foldername] ] [ -V[level] ] [ -W[-|+]pen ] [ -Zargs ] [ -bibinary ] [ -dinodata ]
[ -fflags ] [ -hheaders ] [ -iflags ] [ -:[i|o] ] [ > output.kml ]
Note: No space is allowed between the option flag and the associated arguments.
1.9.2 Description
gmt2kml reads one or more GMT table file and converts them to a single output file using Google
Earths KML format. Data may represent points, lines, or polygons, and you may specify additional
attributes such as title, altitude mode, colors, pen widths, transparency, regions, and data descriptions.
You may also extend the feature down to ground level (assuming it is above it) and use custom icons for
point symbols.
The input files should contain the following columns:
lon lat [ alt ] [ timestart [ timestop ] ]
where lon and lat are required for all features, alt is optional for all features (see also -A and -C), and
timestart and timestop apply to events and timespan features.
46
1.9. gmt2kml
47
-W[-|+]pen Set pen attributes for lines or polygon outlines. Append pen attributes to use [Defaults:
width = default, color = black, style = solid]. If -C is given you may optionally use -W- to apply
the cpt color to the polygon outline only (fill determined by -G) or -W+ to use the cpt color for
both polygon fill and outline. Note that for KML the pen width is given as integer pixel widths so
you must specify pen width as np, where n is an integer.
-Zargs Set one or more attributes of the Document and Region tags. Append +aalt_min/alt_max to
specify limits on visibility based on altitude. Append +llod_min/lod_max to specify limits on
visibility based on Level Of Detail, where lod_max == -1 means it is visible to infinite size.
Append +ffade_min/fade_max to fade in and out over a ramp [abrupt]. Append +v to make a
feature not visible when loaded [visible]. Append +o to open a folder or document in the sidebar
when loaded [closed].
-bi[ncols][t] (more ...) Select native binary input. [Default is 2 input columns].
-dinodata (more ...) Replace input columns that equal nodata with NaN.
-f[i|o]colinfo (more ...) Specify data types of input and/or output columns.
-g[a]x|y|d|X|Y|D|[col]z[+|-]gap[u] (more ...) Determine data gaps and line breaks.
-h[i|o][n][+c][+d][+rremark][+rtitle] (more ...) Skip or produce header record(s).
-icols[l][sscale][ooffset][,...] (more ...) Select input columns (0 is first column).
-:[i|o] (more ...) Swap 1st and 2nd column on input and/or output.
-^ or just - Print a short message about the syntax of the command, then exits (NOTE: on Windows use
just -).
-+ or just + Print an extensive usage (help) message, including the explanation of any module-specific
option (but not the GMT common options), then exits.
-? or no arguments Print a complete usage (help) message, including the explanation of options, then
exits.
1.9.5 Examples
To convert a file with point locations (lon, lat) into a KML file with red circle symbols, try
gmt2kml mypoints.txt -Gfred -Fs > mypoints.kml
To convert a multisegment file with lines (lon, lat) separated by segment headers that contain a Llabelstring with the feature name, selecting a thick white pen, and title the document, try
gmt2kml mylines.txt -Wthick,white -Fl -T"Lines from here to there" > mylines.kml
To convert a multisegment file with polygons (lon, lat) separated by segment headers that contain a Llabelstring with the feature name, selecting a thick black pen and semi-transparent yellow fill, giving a
title to the document, and prescribing a particular region limit, try
gmt gmt2kml mypolygons.txt -Gfyellow@50 -Fp -T"My polygons" -R30/90/-20/40 >
mypolygons.kml
To convert a file with point locations (lon, lat, time) into a KML file with green circle symbols that will
go active at the specified time and stay active going forward, try
48
awk '{print $1, $2, $3, "NaN"}' mypoints.txt | gmt gmt2kml -Gfgreen -Ft >
mytimepoints.kml
To extract contours and labels every 10 units from the grid temp.nc and plot them in KML, using red
lines at 75% transparency and red labels (no transparency), try
gmt grdcontour temp.nc -Jx1id -A10+tlabel.txt -C10 -Dcontours.txt
gmt gmt2kml
contours.txt -Fl -W1p,red@75 -K > contours.kml
-O -N+ -Fs -Sn2 -Gnred@0 label.txt -I- >> contours.kml
gmt gmt2kml
To instead plot the contours as lines with colors taken from the cpt file contours.cpt, try
gmt gmt2kml contours.txt -Fl -Ccontours.cpt > contours.kml
1.9.6 Limitations
Google Earth has trouble displaying filled polygons across the Dateline. For now you must manually
break any polygon crossing the dateline into a west and east polygon and plot them separately.
1.9. gmt2kml
49
</Folder>
</Folder>
<Folder><name>Line Features</name>
<Folder><name>file1.dat</name>
<!One folder for each input file (not when standard input)>
<Placemark><name>Line 0</name>
<!Here goes the first line segment>
</Placemark>
<Placemark><name>Line 1</name>
<!Here goes the second line segment>
</Placemark>
</Folder>
<Folder>
</Document>
[ KML trailer information; not present if -K was used ]
1.10 gmt5syntax
gmt5syntax - Convert old GMT script to use new gmt <module> syntax
1.10.1 Synopsis
gmt5syntax old_script > new_script
1.10.2 Description
gmt5syntax is a perl script that converts old-style GMT commands in, e.g., shell scripts, to the new
gmt <module>-syntax. This utility is located in the tools subdirectory of the data directory. gmt
--show-datadir will show the path to the latter.
50
1.11 gmtcolors
gmtcolors - Explanation of color codes in GMT
1.11.1 Description
Colors can be specified in GMT as arguments to commands, generally as part of the -G or -W options
to select polygon fill or outline pen. Colors are also used in color palette tables (CPTs) that help convert
numerical values to colors.
GMT allows several ways to represent a color:
Colorname Specify one of the named colors below. All names are case-insensitive.
R/G/B Specify Red, Green, and Blue levels. Each value is separated by a slash and is in the range from
0 (dark) to 255 (light). This representation is used to color monitors.
#RRGGBB Specify Red, Green, and Blue levels in the way that it is done in HTML. Use two characters
for each color channel, ranging from 00 (dark) to FF (light). Upper and lower case are allowed.
Graylevel For shades of gray, R = G = B, and only one number needs to be used. This representation is
popular with black and white printers.
H-S-V Specify Hue in the range 0 to 360 (degrees), S saturation between 0 (not saturated) and 1 (fully
saturated), and value V between 0 (dark) and 1 (light). Number are separated by hyphens. This
representation can be helpful when hue varies a lot.
C/M/Y/K Specify Cyan, Magenta, Yellow, and blacBD(K). Each number is in the range from 0 (no
paint) to 1 (maximum paint). This representation is used by most color printers.
1.11. gmtcolors
G
250
248
250
245
245
240
235
239
235
228
218
222
B
250
255
240
238
230
230
215
213
205
196
185
173
Name
snow
ghostwite
floralwhite
seashell
oldlace
linen
antiquewhite
papayawhip
blanchedalmond
bisque
peachpuff
navajowhite
Continued on next page
51
Table
R
255
255
255
255
240
245
240
240
230
255
255
100
106
123
132
135
135
119
119
112
112
176
173
224
176
175
102
127
144
143
152
124
127
173
154
107
189
240
238
238
255
250
255
128
255
218
184
52
Table
R
188
205
139
160
205
222
245
245
244
210
210
178
235
165
120
233
250
255
255
255
255
255
240
255
255
255
255
139
255
255
255
255
219
176
199
208
139
255
255
238
218
221
186
153
148
138
160
1.11. gmtcolors
Table
R
147
216
105
105
169
169
190
190
211
211
220
245
255
255
238
205
139
255
238
205
139
255
238
205
139
255
238
205
139
255
238
205
139
255
238
205
139
255
238
205
139
255
238
205
139
255
238
54
Table
R
205
139
240
224
193
131
255
238
205
139
255
238
205
139
240
224
193
131
131
122
105
135
126
108
176
164
141
198
185
159
108
202
188
162
110
191
178
154
104
224
209
180
122
187
174
150
102
1.11. gmtcolors
Table
R
152
142
122
151
141
121
127
118
102
193
180
155
105
154
144
124
127
118
102
192
179
154
105
202
188
162
110
255
238
205
139
255
238
205
139
255
238
205
139
255
238
205
139
255
238
205
139
56
Table
R
255
238
205
139
255
238
205
139
255
238
205
139
255
238
205
139
255
238
205
139
255
238
205
139
255
238
205
139
255
238
205
139
255
238
205
139
255
238
205
139
255
238
205
139
255
238
205
1.11. gmtcolors
Table
R
139
255
238
205
139
255
238
205
139
255
238
205
139
255
238
205
139
255
238
205
139
255
238
205
139
255
238
205
139
255
238
205
139
255
238
205
139
255
238
205
139
255
238
205
139
255
238
58
Table
R
205
139
255
238
205
139
255
238
205
139
255
238
205
139
255
238
205
139
255
238
205
139
224
209
180
122
191
178
154
104
155
145
125
171
159
137
255
238
205
139
102
102
105
105
107
107
110
1.11. gmtcolors
Table
R
110
112
112
115
115
117
117
120
120
122
122
125
125
127
127
130
130
133
133
135
135
138
138
140
140
143
143
145
145
148
148
150
150
153
153
156
156
158
158
161
161
163
163
166
166
168
168
60
Table
R
171
171
173
173
176
176
179
179
181
181
184
184
186
186
189
189
191
191
194
194
196
196
199
199
201
201
204
204
207
207
209
209
212
212
214
214
217
217
219
219
222
222
224
224
227
227
229
1.11. gmtcolors
Table
R
229
232
232
235
235
237
237
240
240
242
242
245
245
247
247
250
250
252
252
255
255
1.12 gmtconnect
gmtconnect - Connect individual lines whose end points match within tolerance
1.12.1 Synopsis
gmtconnect [ table ] [ -C[closed] ] [ -D[template] ] [ -L[linkfile] ] [ -Q[template] ] [ T[cutoff [unit][/nn_dist]] ] [ -V[level] ] [ -bbinary ] [ -dnodata ] [ -fflags ] [ -ggaps ] [ -hheaders ] [
-iflags ] [ -oflags ] [ -:[i|o] ]
Note: No space is allowed between the option flag and the associated arguments.
62
1.12.2 Description
gmtconnect reads standard input or one or more data files, which may be multisegment files, and examines the coordinates of the end points of all line segments. If a pair of end points are identical or
closer to each other than the specified separation tolerance then the two line segments are joined into a
single segment. The process repeats until all the remaining endpoints no longer pass the tolerance test;
the resulting segments are then written out to standard output or specified output file. If it is not clear
what the separation tolerance should be then use -L to get a list of all separation distances and analyze
them to determine a suitable cutoff.
1.12. gmtconnect
63
-bo[ncols][type] (more ...) Select native binary output. [Default is same as input].
-d[i|o]nodata (more ...) Replace input columns that equal nodata with NaN and do the reverse on output.
-f[i|o]colinfo (more ...) Specify data types of input and/or output columns.
-g[a]x|y|d|X|Y|D|[col]z[+|-]gap[u] (more ...) Determine data gaps and line breaks.
-h[i|o][n][+c][+d][+rremark][+rtitle] (more ...) Skip or produce header record(s).
-icols[l][sscale][ooffset][,...] (more ...) Select input columns (0 is first column).
-ocols[,...] (more ...) Select output columns (0 is first column).
-:[i|o] (more ...) Swap 1st and 2nd column on input and/or output.
-^ or just - Print a short message about the syntax of the command, then exits (NOTE: on Windows use
just -).
-+ or just + Print an extensive usage (help) message, including the explanation of any module-specific
option (but not the GMT common options), then exits.
-? or no arguments Print a complete usage (help) message, including the explanation of options, then
exits.
1.12.5 Units
For map distance unit, append unit d for arc degree, m for arc minute, and s for arc second, or e for
meter [Default], f for foot, k for km, M for statute mile, n for nautical mile, and u for US survey foot.
By default we compute such distances using a spherical approximation with great circles. Prepend - to
a distance (or the unit is no distance is given) to perform Flat Earth calculations (quicker but less
accurate) or prepend + to perform exact geodesic calculations (slower but more accurate).
1.12.7 Examples
To combine the digitized segment lines segment_*.txt (whose coordinates are in cm) into as few complete lines as possible, assuming the end points slop could be up to 0.1 mm, run
gmt connect segment_*.txt -Tf0.1 > new_segments.txt
To combine the digitized segments in the multisegment file my_lines.txt (whose coordinates are in
lon,lat) into as few complete lines as possible, assuming the end points slop could be up to 150 m, and
write the complete segments to separate files called Map_segment_0001.dat, Map_segment_0002.dat,
etc., run
64
1.12.8 Bugs
The line connection does not work if a line only has a single point. However, gmtconnect will correctly
add the point to the nearest segment. Running gmtconnect again on the new set of lines will eventually
connect all close lines.
1.13 gmtconvert
gmtconvert - Convert, Paste, and/or Extract columns from data tables
1.13.1 Synopsis
gmtconvert [ table ] [ -A ] [ -C[+lmin][+umax][+i]] [ -D[template[+oorig]] ] [ -E[f|l|mstride] ] [ -L
] [ -F[c|n|r|v][refpoint] ] [ -I[tsr] ] [ -Q[~]selection] [ -S[~]search string | -S[~]/regexp/[i] ] [ -T ] [
-V[level] ] [ -aflags ] [ -bbinary ] [ -dnodata ] [ -fflags ] [ -ggaps ] [ -hheaders ] [ -iflags ] [ -oflags ] [
-sflags ] [ -:[i|o] ]
Note: No space is allowed between the option flag and the associated arguments.
1.13.2 Description
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.
1.13. gmtconvert
65
-A The records from the input files should be pasted horizontally, not appended vertically [Default]. All
files must have the same number of segments and number of rows per segment. Note for binary
input, all the files you want to paste must have the same number of columns (as set with -bi);
ASCII tables can have different number of columns.
-C[+lmin][+umax][+i] Only output segments whose number of records matches your given criteria:
Append +lmin to ensure all segment must have at least min records to be written to output [0], and
append +umax to ensure all segments must have at most max records to be written [inf]. You may
append +i to invert the selection, i.e., only segments with record counts outside the given range
will be output.
-D[template[+oorig]] For multiple segment data, dump each segment to a separate output file [Default
writes a multiple segment file to stdout]. Append a format template for the individual file names;
this template must contain a C format specifier that can format an integer argument (the running
segment number across all tables); this is usually %d but could be %08d which gives leading
zeros, etc. [Default is gmtconvert_segment_%d.{txt|bin}, depending on -bo]. Append +oorig to
start the numbering from orig instead of zero. Alternatively, give a template with two C format
specifiers and we will supply the table number and the segment number within the table to build
the file name. Append +otorig/sorig to start the numbering of tables from torig and numbering of
segments within a table from sorig instead of zero. The +o modifier will be stripped off before the
template is used.
-E[f|l|mstride] Only extract the first and last record for each segment of interest [Default extracts all
records]. Optionally, append f or l to only extract the first or last record of each segment, respectively. Alternatively, append mstride to extract only one out of stride records.
-F[c|n|r|v][refpoint] Alter the way points are connected (by specifying a scheme) and data are grouped
(by specifying a method). Append one of four line connection schemes: c: Form continuous line
segments for each group [Default]. r: Form line segments from a reference point reset for each
group. n: Form networks of line segments between all points in each group. v: Form vector line
segments suitable for psxy -Sv+s. Optionally, append the one of four segmentation methods to
define the group: a: Ignore all segment headers, i.e., let all points belong to a single group, and
set group reference point to the very first point of the first file. f: Consider all data in each file
to be a single separate group and reset the group reference point to the first point of each group.
s: Segment headers are honored so each segment is a group; the group reference point is reset to
the first point of each incoming segment [Default]. r: Same as s, but the group reference point is
reset after each record to the previous point (this method is only available with the -Fr scheme).
Instead of the codes a|f|s|r you may append the coordinates of a refpoint which will serve as a
fixed external reference point for all groups.
-I[tsr] Invert the order of items, i.e., output the items in reverse order, starting with the last and ending
up with the first item [Default keeps original order]. Append up to three items that should be
reversed: t will reverse the order of tables, s will reverse the order of segments within each table,
and r will reverse the order of records within each segment [Default].
-L Only output a listing of all segment header records and no data records (requires ASCII data).
-Q[~]selection Only write segments whose number is included in selection and skip all others. Cannot
be used with -S. The selection syntax is range[,range,...] where each range of items is either a
single segment number or a range with stepped increments given via start[:step:]:stop (step is
optional and defaults to 1). A leading ~ will invert the selection and write all segments but the
ones listed. Instead of a list of ranges, use +ffile to supply a file list with one range per line.
-S[~]search string or -S[~]/regexp/[i] Only output those segments whose header record contains the
specified text string. To reverse the search, i.e., to output segments whose headers do not con-
66
tain the specified pattern, use -S~. Should your pattern happen to start with ~ you need to escape this character with a backslash [Default output all segments]. Cannot be used with -Q. For
matching segments based on aspatial values (via OGR/GMT format), give the search string as
varname=value and we will compare value against the value of varname for each segment. Note:
If the features are polygons then a match of a particular polygon perimeter also means that any
associated polygon holes will also be matched. For matching segment headers against extended
regular expressions enclose the expression in slashes. Append i for case-insensitive matching. For
a list of such patterns, give +ffile with one pattern per line. To give a single pattern starting with
+f, escape it with a backslash.
-T Suppress the writing of segment headers on output.
-V[level] (more ...) Select verbosity level [c].
-acol=name[...] (more ...) Set aspatial column associations col=name.
-bi[ncols][t] (more ...) Select native binary input.
-bo[ncols][type] (more ...) Select native binary output. [Default is same as input].
-d[i|o]nodata (more ...) Replace input columns that equal nodata with NaN and do the reverse on output.
-f[i|o]colinfo (more ...) Specify data types of input and/or output columns.
-g[a]x|y|d|X|Y|D|[col]z[+|-]gap[u] (more ...) Determine data gaps and line breaks.
-h[i|o][n][+c][+d][+rremark][+rtitle] (more ...) Skip or produce header record(s).
-icols[l][sscale][ooffset][,...] (more ...) Select input columns (0 is first column).
-ocols[,...] (more ...) Select output columns (0 is first column).
-s[cols][a|r] (more ...) Set handling of NaN records.
-:[i|o] (more ...) Swap 1st and 2nd column on input and/or output.
-^ or just - Print a short message about the syntax of the command, then exits (NOTE: on Windows use
just -).
-+ or just + Print an extensive usage (help) message, including the explanation of any module-specific
option (but not the GMT common options), then exits.
-? or no arguments Print a complete usage (help) message, including the explanation of options, then
exits.
1.13.6 Examples
To convert the binary file test.b (single precision) with 4 columns to ASCII:
1.13. gmtconvert
67
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 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
To write all segments in the two files A.txt and B.txt to individual files named profile_005000.txt, profile_005001.txt, etc., where we reset the origin of the sequential numbering from 0 to 5000, try
68
1.14 gmtdefaults
gmtdefaults - List current GMT default parameters
1.14.1 Synopsis
gmtdefaults [ -D[u|s] ]
Note: No space is allowed between the option flag and the associated arguments.
1.14.2 Description
gmtdefaults lists the GMT parameter defaults if the option -D is used. There are three ways to change
some of the settings: (1) Use the command gmtset, (2) use any text editor to edit the file gmt.conf in your
home, ~/.gmt or current directory (if you do not have this file, run gmtset -D to get one with the system
default settings), or (3) override any parameter by specifying one or more --PARAMETER=VALUE
statements on the command line of any GMT command (PARAMETER and VALUE are any combination listed below). The first two options are permanent changes until explicitly changed back, while the
last option is ephemeral and only applies to the single GMT command that received the override. GMT
can provide default values in US or SI units. This choice is determined at compile time.
69
1.14.6 Examples
To get a copy of the GMT parameter defaults in your home directory, run
gmt defaults -D > ~/gmt.conf
You may now change the settings by editing this file using a text editor of your choice, or use gmtset to
change specified parameters on the command line.
1.14.7 Bugs
If you have typographical errors in your gmt.conf file(s), a warning message will be issued, and the
GMT defaults for the affected parameters will be used.
1.15 gmtget
gmtget - Get individual GMT default parameters
1.15.1 Synopsis
gmtget [ -Gdefaultsfile ] [ -L ] PARAMETER1 [ PARAMETER2 PARAMETER3 ... ]
Note: No space is allowed between the option flag and the associated arguments.
1.15.2 Description
gmtget will list the value of one or more GMT default parameters.
70
1.15.5 Example
To list the value of the parameter PS_COMMENTS:
gmt get PS_COMMENTS
and
1.16 gmtinfo
gmtinfo - Get information about data tables
1.16.1 Synopsis
gmtinfo [ table ] [ -Aa|f|s ] [ -C ] [ -D[dx[/dy]] ] [ -EL|l|H|hcol ] [ -I[p|f|s]dx[/dy[/dz...] ] [ -L ] [ -S[x][y]
] [ -Tdz[/col] ] [ -V[level] ] [ -bibinary ] [ -dinodata ] [ -fflags ] [ -ggaps ] [ -hheaders ] [ -iflags ] [
-oflags ] [ -r ] [ -:[i|o] ]
Note: No space is allowed between the option flag and the associated arguments.
1.16.2 Description
gmtinfo reads its standard input [or from files] and finds the extreme values in each of the columns. It
recognizes NaNs and will print warnings if the number of columns vary from record to record. As an
option, gmtinfo will find the extent of the first n columns rounded up and down to the nearest multiple of
the supplied increments. By default, this output will be in the form -Rw/e/s/n which can be used directly
in the command line for other programs (hence only dx and dy are needed), or the output will be in
column form for as many columns as there are increments provided. A similar option (-T) will provide
a -Tzmin/zmax/dz string for makecpt.
71
72
-^ or just - Print a short message about the syntax of the command, then exits (NOTE: on Windows use
just -).
-+ or just + Print an extensive usage (help) message, including the explanation of any module-specific
option (but not the GMT common options), then exits.
-? or no arguments Print a complete usage (help) message, including the explanation of options, then
exits.
1.16.6 Examples
To find the extreme values in the file ship_gravity.xygd:
gmt info ship_gravity.xygd
To find the extreme values in the file track.xy to the nearest 5 units but shifted to within 1 unit of the data
center, and use this region to draw a line using psxy, run
gmt psxy `gmt info -I5 -D1 track.xy` track.xy -Jx1 -B5 -P > track.ps
To find the min and max values for each of the first 4 columns, but rounded to integers, and return the
result individually for each data file, use
gmt info profile_*.txt -C -I1/1/1/1
Given seven profiles with different start and stop positions, we want to find a range of positions, with
increment of 5, that are common to all the profiles. We use
gmt info profile_[123567].txt -L -I5
1.16.7 Bugs
The -I option does not yet work properly with time series data (e.g., -f0T). Thus, such variable intervals
as months and years are not calculated. Instead, specify your interval in the same units as the current
setting of TIME_UNIT.
73
1.17 gmtlogo
gmtlogo - Place the GMT graphics logo on a map
1.17.1 Synopsis
gmtlogo
[
-D[g|j|J|n|x]refpoint+wwidth[+jjustify][+odx[/dy]]
]
[
F[+cclearances][+gfill][+i[[gap/]*pen*]][+p[pen]][+r[radius]][+s[[dx/dy/][shade]]] ] [ -Jparameters
] [ -Jz|Zparameters ] [ -K ] [ -O ] [ -P ] [ -Rwest/east/south/north[/zmin/zmax][r] ] [ -U[stamp] ] [
-V[level] ] [ -Xx_offset ] [ -Yy_offset ] [ -ccopies ] [ -ttransp ]
Note: No space is allowed between the option flag and the associated arguments.
1.17.2 Description
This module plots the GMT logo on a map. By default, the GMT logo is 2 inches wide and 1 inch high
and will be positioned relative to the current plot origin. Use various options to change this and to place
a transparent or opaque rectangular map panel behind the GMT logo.
1.17.5 Examples
To plot the GMT logo of a 2 inch width as a stand-alone plot, use
gmt logo -P -Dx0/0+w2i > logo.ps
To append a GMT logo overlay in the upper right corner of the current map, but scaled up to be 3 inches
wide and offset by 0.1 inches from the border, try
gmt logo -O -K -R -J -DjTR+o0.1i/0.1i+w3i >> bigmap.ps
1.18 gmtmath
gmtmath - Reverse Polish Notation (RPN) calculator for data tables
1.18.1 Synopsis
gmtmath [ -At_f(t).d[+e][+s|w] ] [ -Ccols ] [ -Eeigen ] [ -I ] [ -Nn_col[/t_col] ] [ -Q ] [ -S[f|l] ] [ Tt_min/t_max/t_inc[+]|tfile ] [ -V[level] ] [ -bbinary ] [ -dnodata ] [ -fflags ] [ -ggaps ] [ -hheaders ] [
-iflags ] [ -oflags ] [ -sflags ] operand [ operand ] OPERATOR [ operand ] OPERATOR ... = [ outfile ]
Note: No space is allowed between the option flag and the associated arguments.
1.18. gmtmath
75
1.18.2 Description
gmtmath will perform operations like add, subtract, multiply, and divide on one or more table data
files or constants using Reverse Polish Notation (RPN) syntax (e.g., Hewlett-Packard calculator-style).
Arbitrarily complicated expressions may therefore be evaluated; the final result is written to an output file
[or standard output]. Data operations are element-by-element, not matrix manipulations (except where
noted). Some operators only require one operand (see below). If no data tables are used in the expression
then options -T, -N can be set (and optionally -bo to indicate the data type for binary tables). If STDIN
is given, the standard input will be read and placed on the stack as if a file with that content had been
given on the command line. By default, all columns except the time column are operated on, but this
can be changed (see -C). Complicated or frequently occurring expressions may be coded as a macro for
future use or stored and recalled via named memory locations.
76
-S[f|l] Only report the first or last row of the results [Default is all rows]. This is useful if you have
computed a statistic (say the MODE) and only want to report a single number instead of numerous
records with identical values. Append l to get the last row and f to get the first row only [Default].
-Tt_min/t_max/t_inc[+]|tfile Required when no input files are given. Sets the t-coordinates of the first
and last point and the equidistant sampling interval for the time column (see -N). Append + if
you are specifying the number of equidistant points instead. If there is no time column (only data
columns), give -T with no arguments; this also implies -Ca. Alternatively, give the name of a file
whose first column contains the desired t-coordinates which may be irregular.
-V[level] (more ...) Select verbosity level [c].
-bi[ncols][t] (more ...) Select native binary input.
-bo[ncols][type] (more ...) Select native binary output. [Default is same as input, but see -o]
-d[i|o]nodata (more ...) Replace input columns that equal nodata with NaN and do the reverse on output.
-f[i|o]colinfo (more ...) Specify data types of input and/or output columns.
-g[a]x|y|d|X|Y|D|[col]z[+|-]gap[u] (more ...) Determine data gaps and line breaks.
-h[i|o][n][+c][+d][+rremark][+rtitle] (more ...) Skip or produce header record(s).
-icols[l][sscale][ooffset][,...] (more ...) Select input columns (0 is first column).
-ocols[,...] (more ...) Select output columns (0 is first column).
-s[cols][a|r] (more ...) Set handling of NaN records.
-^ or just - Print a short message about the syntax of the command, then exits (NOTE: on Windows use
just -).
-+ or just + Print an extensive usage (help) message, including the explanation of any module-specific
option (but not the GMT common options), then exits.
-? or no arguments Print a complete usage (help) message, including the explanation of options, then
exits.
1.18.5 Operators
Choose among the following 176 operators. args are the number of input and output arguments.
Operator
ABS
ACOS
ACOSH
ACSC
ACOT
ADD
AND
ASEC
ASIN
ASINH
ATAN
args
11
11
11
11
11
21
21
11
11
11
11
Returns
abs (A)
acos (A)
acosh (A)
acsc (A)
acot (A)
A+B
B if A == NaN, else A
asec (A)
asin (A)
asinh (A)
atan (A)
1.18. gmtmath
77
ATAN2
ATANH
BCDF
BPDF
BEI
BER
BITAND
BITLEFT
BITNOT
BITOR
BITRIGHT
BITTEST
BITXOR
CEIL
CHICRIT
CHICDF
CHIPDF
COL
COMB
CORRCOEFF
COS
COSD
COSH
COT
COTD
CSC
CSCD
DDT
D2DT2
D2R
DENAN
DILOG
DIFF
DIV
DUP
ECDF
ECRIT
EPDF
ERF
ERFC
ERFINV
EQ
EXCH
EXP
FACT
FCDF
FCRIT
FLIPUD
78
21
11
31
31
11
11
21
21
11
21
21
21
21
11
21
21
21
11
21
21
11
11
11
11
11
11
11
11
11
11
21
11
11
21
12
21
21
21
11
11
11
21
22
11
11
31
31
11
FLOOR
FMOD
FPDF
GE
GT
HYPOT
I0
I1
IFELSE
IN
INRANGE
INT
INV
ISFINITE
ISNAN
J0
J1
JN
K0
K1
KN
KEI
KER
KURT
LCDF
LCRIT
LE
LMSSCL
LMSSCLW
LOG
LOG10
LOG1P
LOG2
LOWER
LPDF
LRAND
LSQFIT
LT
MAD
MADW
MAX
MEAN
MEANW
MEDIAN
MEDIANW
MIN
MOD
MODE
1.18. gmtmath
11
21
31
21
21
21
11
11
31
21
31
11
11
11
11
11
11
21
11
11
21
11
11
11
11
11
21
11
21
11
11
11
11
11
11
21
10
21
11
21
21
11
21
11
21
21
21
11
MODEW
MUL
NAN
NEG
NEQ
NORM
NOT
NRAND
OR
PCDF
PERM
PPDF
PLM
PLMg
POP
POW
PQUANT
PQUANTW
PSI
PV
QV
R2
R2D
RAND
RCDF
RCRIT
RINT
RMS
RPDF
ROLL
ROTT
SEC
SECD
SIGN
SIN
SINC
SIND
SINH
SKEW
SQR
SQRT
STD
STDW
STEP
STEPT
SUB
SUM
TAN
80
21
21
21
11
21
11
11
21
21
21
21
21
31
31
10
21
21
31
11
31
31
21
11
21
11
11
11
11
11
20
21
11
11
11
11
11
11
11
11
11
11
11
21
11
11
21
11
11
TAND
TANH
TAPER
TN
TCRIT
TPDF
TCDF
UPPER
VAR
VARW
WCDF
WCRIT
WPDF
XOR
Y0
Y1
YN
ZCDF
ZPDF
ZCRIT
ROOTS
11
11
11
21
21
21
21
11
11
21
31
31
31
21
11
11
21
11
11
11
21
1.18.6 Symbols
The following symbols have special meaning:
PI
E
EULER
EPS_F
EPS_D
TMIN
TMAX
TRANGE
TINC
N
T
TNORM
TROW
3.1415926...
2.7182818...
0.5772156...
1.192092896e-07 (sgl. prec. eps)
2.2204460492503131e-16 (dbl. prec. eps)
Minimum t value
Maximum t value
Range of t values
t increment
The number of records
Table with t-coordinates
Table with normalized t-coordinates
Table with row numbers 1, 2, ..., N-1
1.18. gmtmath
81
1.18.10 Macros
Users may save their favorite operator combinations as macros via the file gmtmath.macros in their
current or user directory. The file may contain any number of macros (one per record); comment lines
starting with # are skipped. The format for the macros is name = arg1 arg2 ... arg2 [ : comment]
where name is how the macro will be used. When this operator appears on the command line we simply
replace it with the listed argument list. No macro may call another macro. As an example, the following
macro expects that the time-column contains seafloor ages in Myr and computes the predicted half-space
bathymetry:
DEPTH = SQRT 350 MUL 2500 ADD NEG : usage: DEPTH to return half-space seafloor depths
82
Note: Because geographic or time constants may be present in a macro, it is required that the optional
comment flag (:) must be followed by a space. As another example, we show a macro GPSWEEK
which determines which GPS week a timestamp belongs to:
GPSWEEK = 1980-01-06T00:00:00 SUB 86400 DIV 7 DIV FLOOR : GPS week without rollover
1.18.12 Examples
To take the square root of the content of the second data column being piped through gmtmath by
process1 and pipe it through a 3rd process, use
process1 | gmt math STDIN SQRT = | process3
Given the file samples.d, which holds seafloor ages in m.y. and seafloor depth in m, use the relation
depth(in m) = 2500 + 350 * sqrt (age) to print the depth anomalies:
gmt math samples.d T SQRT 350 MUL 2500 ADD SUB = | lpr
To take the average of columns 1 and 4-6 in the three data sets sizes.1, sizes.2, and sizes.3, use
gmt math -C1,4-6 sizes.1 sizes.2 ADD sizes.3 ADD 3 DIV = ave.d
To take the 1-column data set ages.d and calculate the modal value and assign it to a variable, try
gmt set mode_age = `gmt math -S -T ages.d MODE =`
To evaluate the dilog(x) function for coordinates given in the file t.d:
gmt math -Tt.d T DILOG = dilog.d
To demonstrate the use of stored variables, consider this sum of the first 3 cosine harmonics where we
store and repeatedly recall the trigonometric argument (2*pi*T/360):
gmt math -T0/360/1 2 PI MUL 360 DIV T MUL STO@kT COS @kT 2 MUL COS ADD \
@kT 3 MUL COS ADD = harmonics.d
To use gmtmath as a RPN Hewlett-Packard calculator on scalars (i.e., no input files) and calculate arbitrary expressions, use the -Q option. As an example, we will calculate the value of Kei (((1 + 1.75)/2.2)
+ cos (60)) and store the result in the shell variable z:
set z = `gmt math -Q 1 1.75 ADD 2.2 DIV 60 COSD ADD KEI =`
1.18. gmtmath
83
To use gmtmath as a general least squares equation solver, imagine that the current table is the augmented matrix [ A | b ] and you want the least squares solution x to the matrix equation A * x = b.
The operator LSQFIT does this; it is your job to populate the matrix correctly first. The -A option will
facilitate this. Suppose you have a 2-column file ty.d with t and b(t) and you would like to fit a the
model y(t) = a + b*t + c*H(t-t0), where H is the Heaviside step function for a given t0 = 1.55. Then, you
need a 4-column augmented table loaded with t in column 1 and your observed y(t) in column 3. The
calculation becomes
gmt math -N4/1 -Aty.d -C0 1 ADD -C2 1.55 STEPT ADD -Ca LSQFIT = solution.d
Note we use the -C option to select which columns we are working on, then make active all the columns
we need (here all of them, with -Ca) before calling LSQFIT. The second and fourth columns (col
numbers 1 and 3) are preloaded with t and y(t), respectively, the other columns are zero. If you already
have a pre-calculated table with the augmented matrix [ A | b ] in a file (say lsqsys.d), the least squares
solution is simply
gmt math -T lsqsys.d LSQFIT = solution.d
Users must be aware that when -C controls which columns are to be active the control extends to placing
columns from files as well. Contrast the different result obtained by these very similar commands:
echo 1 2 3 4 | gmt math STDIN -C3 1 ADD =
1
2
3
5
versus
echo 1 2 3 4 | gmt math -C3 STDIN 1 ADD =
0
0
0
5
1.18.13 References
Abramowitz, M., and I. A. Stegun, 1964, Handbook of Mathematical Functions, Applied Mathematics
Series, vol. 55, Dover, New York.
Holmes, S. A., and W. E. Featherstone, 2002, A unified approach to the Clenshaw summation and the
recursive computation of very high degree and order normalized associated Legendre functions. Journal
of Geodesy, 76, 279-299.
Press, W. H., S. A. Teukolsky, W. T. Vetterling, and B. P. Flannery, 1992, Numerical Recipes, 2nd edition,
Cambridge Univ., New York.
Spanier, J., and K. B. Oldman, 1987, An Atlas of Functions, Hemisphere Publishing Corp.
1.19 gmtregress
gmtregress - Linear regression of 1-D data sets
84
1.19.1 Synopsis
gmtregress [ table ] [ -Amin/max/inc ] [ -Clevel ] [ -Ex|y|o|r ] [ -Fflags ] [ -N1|2|r|w ] [ -S[r] ] [ Tmin/max/inc | -Tn ] [ -W[w][x][y][r] ] [ -V[level] ] [ -aflags ] [ -bbinary ] [ -ggaps ] [ -hheaders ] [
-iflags ] [ -oflags ]
Note: No space is allowed between the option flag and the associated arguments.
1.19.2 Description
gmtregress reads one or more data tables [or stdin] and determines the best linear regression model
y = a + b* x for each segment using the chosen parameters. The user may specify which data and
model components should be reported. By default, the model will be evaluated at the input points, but
alternatively you can specify an equidistant range over which to evaluate the model, or turn off evaluation
completely. Instead of determining the best fit we can perform a scan of all possible regression lines (for a
range of slope angles) and examine how the chosen misfit measure varies with slope. This is particularly
useful when analyzing data with many outliers. Note: If you actually need to work with log10 of x or y
you can accomplish that transformation during read by using the -i option.
85
just give -Fp and we instead write a single record with the model parameters npoints xmean ymean
angle misfit slope intercept sigma_slope sigma_intercept.
-N1|2|r|w Selects the norm to use for the misfit calculation. Choose among 1 (L-1 measure; the mean
of the absolute residuals), 2 (Least-squares; the mean of the squared residuals), r (LMS; The
least median of the squared residuals), or w (RLS; Reweighted Least Squares: the mean of the
squared residuals after outliers identified via LMS have been removed) [Default is 2]. Traditional
regression uses L-2 while L-1 and in particular LMS are more robust in how they handle outliers.
As alluded to, RLS implies an initial LMS regression which is then used to identify outliers in the
data, assign these a zero weight, and then redo the regression using a L-2 norm.
-S[r] Restricts which records will be output. By default all data records will be output in the format
specified by -F. Use -S to exclude data points identified as outliers by the regression. Alternatively,
use -Sr to reverse this and only output the outlier records.
-Tmin/max/inc | -Tn Evaluate the best-fit regression model at the equidistant points implied by the
arguments. If -Tn is given instead we will reset min and max to the extreme x-values for each
segment and determine inc so that there are exactly n output values for each segment. To skip the
model evaluation entirely, simply provide -T0.
-W[w][x][y][r] Specifies weighted regression and which weights will be provided. Append x if giving
1-sigma uncertainties in the x-observations, y if giving 1-sigma uncertainties in y, and r if giving
correlations between x and y observations, in the order these columns appear in the input (after
the two required and leading x, y columns). Giving both x and y (and optionally r) implies an orthogonal regression, otherwise giving x requires -Ex and y requires -Ey. We convert uncertainties
in x and y to regression weights via the relationship weight = 1/sigma. Use -Ww if the we should
interpret the input columns to have precomputed weights instead. Note: residuals with respect to
the regression line will be scaled by the given weights. Most norms will then square this weighted
residual (-N1 is the only exception).
-V[level] (more ...) Select verbosity level [c].
-acol=name[...] (more ...) Set aspatial column associations col=name.
-bi[ncols][t] (more ...) Select native binary input.
-bo[ncols][type] (more ...) Select native binary output. [Default is same as input].
-g[a]x|y|d|X|Y|D|[col]z[+|-]gap[u] (more ...) Determine data gaps and line breaks.
-h[i|o][n][+c][+d][+rremark][+rtitle] (more ...) Skip or produce header record(s).
-icols[l][sscale][ooffset][,...] (more ...) Select input columns (0 is first column).
-ocols[,...] (more ...) Select output columns (0 is first column).
-^ or just - Print a short message about the syntax of the command, then exits (NOTE: on Windows use
just -).
-+ or just + Print an extensive usage (help) message, including the explanation of any module-specific
option (but not the GMT common options), then exits.
-? or no arguments Print a complete usage (help) message, including the explanation of options, then
exits.
86
1.19.6 Examples
To do a standard least-squares regression on the x-y data in points.txt and return x, y, and model prediction with 99% confidence intervals, try
gmt regress points.txt -Fxymc -C99 > points_regressed.txt
To do a reweighted least-squares regression on the data rough.txt and return x, y, model prediction and
the RLS weights, try
gmt regress rough.txt -Fxymw > points_regressed.txt
To do an orthogonal least-squares regression on the data crazy.txt but first take the logarithm of both x
and y, then return x, y, model prediction and the normalized residuals (z-scores), try
gmt regress crazy.txt -Eo -Fxymz -i0-1l > points_regressed.txt
To examine how the orthogonal LMS misfits vary with angle between 0 and 90 in steps of 0.2 degrees
for the same file, try
gmt regress points.txt -A0/90/0.2 -Eo -Nr > points_analysis.txt
1.19.7 References
Draper, N. R., and H. Smith, 1998, Applied regression analysis, 3rd ed., 736 pp., John Wiley and Sons,
New York.
Rousseeuw, P. J., and A. M. Leroy, 1987, Robust regression and outlier detection, 329 pp., John Wiley
and Sons, New York.
York, D., N. M. Evensen, M. L. Martinez, and J. De Basebe Delgado, 2004, Unified equations for the
slope, intercept, and standard errors of the best straight line, Am. J. Phys., 72(3), 367-375.
1.19. gmtregress
87
1.20 gmtselect
gmtselect - Select data table subsets based on multiple spatial criteria
1.20.1 Synopsis
gmtselect [ table ] [ -Amin_area[/min_level/max_level][+ag|i|s|S][+r|l][ppercent] ] [ Cpointfile+ddist[unit] ] [ -Dresolution[+] ] [ -E[fn] ] [ -Fpolygonfile ] [ -Ggridmask ] [ -I[cfglrsz] ]
[ -Jparameters ] [ -Llinefile+ddist[unit][+p] ] [ -Nmaskvalues ] [ -Rregion ] [ -Zmin[/max][+ccol] ] [
-V[level] ] [ -bbinary ] [ -dnodata ] [ -fflags ] [ -ggaps ] [ -hheaders ] [ -iflags ] [ -oflags ] [ -:[i|o] ]
Note: No space is allowed between the option flag and the associated arguments.
1.20.2 Description
gmtselect is a filter that reads (longitude, latitude) positions from the first 2 columns of infiles [or standard input] and uses a combination of 1-7 criteria to pass or reject the records. Records can be selected
based on whether or not they are 1) inside a rectangular region (-R [and -J]), 2) within dist km of any
point in pointfile, 3) within dist km of any line in linefile, 4) inside one of the polygons in the polygonfile,
5) inside geographical features (based on coastlines), 6) has z-values within a given range, or 7) inside
bins of a grid mask whose nodes are non-zero. The sense of the tests can be reversed for each of these 6
criteria by using the -I option. See option -: on how to read (latitude,longitude) files.
88
-Dresolution[+] Ignored unless -N is set. Selects the resolution of the coastline data set to use ((f)ull,
(h)igh, (i)ntermediate, (l)ow, or (c)rude). The resolution drops off by ~80% between data sets.
[Default is l]. Append (+) to automatically select a lower resolution should the one requested
not be available [abort if not found]. Note that because the coastlines differ in details it is not
guaranteed that a point will remain inside [or outside] when a different resolution is selected.
-E[fn] Specify how points exactly on a polygon boundary should be considered. By default, such points
are considered to be inside the polygon. Append n and/or f to change this behavior for the -F and
-N options, respectively, so that boundary points are considered to be outside.
-Fpolygonfile Pass all records whose location is within one of the closed polygons in the multiplesegment file polygonfile. For spherical polygons (lon, lat), make sure no consecutive points are
separated by 180 degrees or more in longitude. Note that polygonfile must be in ASCII regardless
of whether -bi is used.
-Ggridmask
Pass all locations that are inside the valid data area of the grid gridmask. Nodes that are outside are either NaN or zero.
-I[cflrsz] Reverses the sense of the test for each of the criteria specified:
c select records NOT inside any points circle of influence.
f select records NOT inside any of the polygons.
g will pass records inside the cells with z equal zero of the grid mask in -G.
l select records NOT within the specified distance of any line.
r select records NOT inside the specified rectangular region.
s select records NOT considered inside as specified by -N (and -A, -D).
z select records NOT within the range specified by -Z.
-Jparameters (more ...) Select map projection.
-Llinefile+ddist[unit][+p] Pass all records whose location is within dist of any of the line segments in
the ASCII multiple-segment file linefile. If dist is zero then we will scan each sub-header in the
linefile for an embedded -Ddist setting that sets each lines individual distance value. Distances
are Cartesian and in user units; specify -fg to indicate spherical distances append a distance unit
(see UNITS). Alternatively, if -R and -J are used then geographic coordinates are projected to
map coordinates (in cm, inch, m, or points, as determined by PROJ_LENGTH_UNIT) before
Cartesian distances are compared to dist. Append +p to ensure only points whose orthogonal
projections onto the nearest line-segment fall within the segments endpoints [Default considers
points beyond the lines endpoints.
-Nmaskvalues Pass all records whose location is inside specified geographical features. Specify if
records should be skipped (s) or kept (k) using 1 of 2 formats:
-Nwet/dry.
-Nocean/land/lake/island/pond.
[Default is s/k/s/k/s (i.e., s/k), which passes all points on dry land].
-R[unit]xmin/xmax/ymin/ymax[r] (more ...) Specify the region of interest. If no map projection is supplied we implicitly set -Jx1.
-V[level] (more ...) Select verbosity level [c].
1.20. gmtselect
89
-Zmin[/max][+ccol] Pass all records whose 3rd column (z; col = 2) lies within the given range or is
NaN (use -s to skip NaN records). If max is omitted then we test if z equals min instead. Input file
must have at least three columns. To indicate no limit on min or max, specify a hyphen (-). If your
3rd column is absolute time then remember to supply -f2T. To specify another column, append
+ccol, and to specify several tests just repeat the Z option as many times has you have columns to
test. Note: when more than one Z option is given then the Iz option cannot be used.
-bi[ncols][t] (more ...) Select native binary input. [Default is 2 input columns].
-bo[ncols][type] (more ...) Select native binary output. [Default is same as input].
-d[i|o]nodata (more ...) Replace input columns that equal nodata with NaN and do the reverse on output.
-f[i|o]colinfo (more ...) Specify data types of input and/or output columns.
-g[a]x|y|d|X|Y|D|[col]z[+|-]gap[u] (more ...) Determine data gaps and line breaks.
-h[i|o][n][+c][+d][+rremark][+rtitle] (more ...) Skip or produce header record(s).
-icols[l][sscale][ooffset][,...] (more ...) Select input columns (0 is first column).
-ocols[,...] (more ...) Select output columns (0 is first column).
-s[cols][a|r] (more ...) Set handling of NaN records.
-:[i|o] (more ...) Swap 1st and 2nd column on input and/or output.
-^ or just - Print a short message about the syntax of the command, then exits (NOTE: on Windows use
just -).
-+ or just + Print an extensive usage (help) message, including the explanation of any module-specific
option (but not the GMT common options), then exits.
-? or no arguments Print a complete usage (help) message, including the explanation of options, then
exits.
1.20.5 Units
For map distance unit, append unit d for arc degree, m for arc minute, and s for arc second, or e for
meter [Default], f for foot, k for km, M for statute mile, n for nautical mile, and u for US survey foot.
By default we compute such distances using a spherical approximation with great circles. Prepend - to
a distance (or the unit is no distance is given) to perform Flat Earth calculations (quicker but less
accurate) or prepend + to perform exact geodesic calculations (slower but more accurate).
90
1.20.10 Examples
To extract the subset of data set that is within 300 km of any of the points in pts.txt but more than 100
km away from the lines in lines.txt, run
gmt select lonlatfile -fg -Cpts.txt+d300k -Llines.txt+d100k -Il > subset
Here, you must specify -fg so the program knows you are processing geographical data.
To keep all points in data.txt within the specified region, except the points on land (as determined by the
high-resolution coastlines), use
gmt select data.txt -R120/121/22/24 -Dh -Nk/s > subset
To return all points in quakes.txt that are inside or on the spherical polygon lonlatpath.txt, try
gmt select quakes.txt -Flonlatpath.txt -fg > subset1
To return all points in stations.txt that are within 5 cm of the point in origin.txt for a certain projection,
try
gmt select stations.txt -Corigin.txt+d5 -R20/50/-10/20 -JM20c \
--PROJ_LENGTH_UNIT=cm > subset2
To return all points in quakes.txt that are inside the grid topo.nc where the values are nonzero, try
gmt select quakes.txt -Gtopo.nc > subset2
1.20. gmtselect
91
1.21 gmtset
gmtset - Change individual GMT default parameters
1.21.1 Synopsis
gmtset [ -C | -D[s|u] | -Gdefaultsfile ] [ -[BJRXxYycp]value ] PARAMETER1 [=] value1 PARAMETER2 [=] value2 PARAMETER3 [=] value3 ...
Note: No space is allowed between the option flag and the associated arguments.
1.21.2 Description
gmtset will adjust individual GMT defaults settings in the current directorys gmt.conf file. If no such
file exists one will be created. The main purpose of gmtset is temporarily to change certain parameters
inside a shell script, e.g., set the dots-per-inch to 72, run the script, and reset to 1200 dpi. Optionally,
you can specify one or more temporary changes directly on any GMT command line with the syntax
--PARAMETER=VALUE; such changes are only in effect for that command and do not permanently
change the default settings on disk.
92
1.21.5 Examples
To change annotation font to 12-point Helvetica, select grid-crosses of size 0.1 inch, and set annotation
offset to 0.2 cm:
gmt set FONT_ANNOT_PRIMARY 12p,Helvetica \
MAP_GRID_CROSS_SIZE_PRIMARY 0.1i MAP_ANNOT_OFFSET_PRIMARY 0.2c
1.22 gmtsimplify
gmtsimplify - Line reduction using the Douglas-Peucker algorithm
1.22.1 Synopsis
gmtsimplify [ table ] -Ttolerance[unit] [ -V[level] ] [ -bbinary ] [ -dnodata ] [ -fflags ] [ -ggaps ] [
-hheaders ] [ -iflags ] [ -oflags ] [ -:[i|o] ]
Note: No space is allowed between the option flag and the associated arguments.
1.22.2 Description
gmtsimplify reads one or more data files and apply the Douglas-Peucker line simplification algorithm.
The method recursively subdivides a polygon until a run of points can be replaced by a straight line
segment, with no point in that run deviating from the straight line by more than the tolerance. Have
1.22. gmtsimplify
93
a look at this site to get a visual insight on how the algorithm works (http://geometryalgorithms.com/
Archive/algorithm_0205/algorithm_0205.htm)
1.22.5 Units
For map distance unit, append unit d for arc degree, m for arc minute, and s for arc second, or e for
meter [Default], f for foot, k for km, M for statute mile, n for nautical mile, and u for US survey foot.
By default we compute such distances using a spherical approximation with great circles. Prepend - to
a distance (or the unit is no distance is given) to perform Flat Earth calculations (quicker but less
accurate) or prepend + to perform exact geodesic calculations (slower but more accurate).
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.
1.22.7 Examples
To reduce the geographic line segment.d using a tolerance of 2 km, run
gmt simplify segment.d -T2k > new_segment.d
To reduce the Cartesian lines xylines.d using a tolerance of 0.45 and write the reduced lines to file
new_xylines.d, run
gmt simplify xylines.d -T0.45 > new_xylines.d
1.22.8 Notes
There is a slight difference in how gmtsimplify processes lines versus closed polygons. Segments that
are explicitly closed will be considered polygons, otherwise we treat them as line segments. Hence,
segments recognized as polygons may reduce to a 3-point polygon with no area; these are suppressed
from the output.
1.22.9 Bugs
One known issue with the Douglas-Peucker has to do with crossovers. Specifically, it cannot be guaranteed that the reduced line does not cross itself. Depending on how many lines you are considering it
is also possible that reduced lines may intersect other reduced lines. Finally, the current implementation
only does Flat Earth calculations even if you specify spherical; gmtsimplify will issue a warning and
reset the calculation mode to Flat Earth.
1.22.10 References
Douglas, D. H., and T. K. Peucker, Algorithms for the reduction of the number of points required to
represent a digitized line of its caricature, Can. Cartogr., 10, 112-122, 1973.
This implementation of the algorithm has been kindly provided by Dr. Gary J. Robinson, Department of
Meteorology, University of Reading, Reading, UK; his subroutine forms the basis for this program.
1.23 gmtspatial
gmtspatial - Geospatial operations on lines and polygons
1.23. gmtspatial
95
1.23.1 Synopsis
gmtspatial [ table ] [ -A[amin_dist][unit]] [ -C ] [ -D[+ffile][+aamax][+ddmax][+c|Ccmax][+sfact]
] [ -E+|- ] [ -F[l] ] [ -I[e|i] ] [ -Npfile[+a][+pstart][+r][+z] ] [ -Q[[|+]*unit*][+cmin[/max]][+h][+l][+p][+s[a|d]] ] [ -Rregion ] [ -Si|u|s|j ] [ -T[clippolygon] ] [ -V[level] ]
[ -bbinary ] [ -dnodata ] [ -fflags ] [ -ggaps ] [ -hheaders ] [ -iflags ] [ -oflags ] [ -:[i|o] ]
Note: No space is allowed between the option flag and the associated arguments.
1.23.2 Description
gmtspatial reads one or more data files (which may be multisegment files) that contains closed polygons
and operates of these polygons in the specified way. Operations include area calculation, handedness
reversals, and polygon intersections.
96
-E+|- ] Reset the handedness of all polygons to match the given + (counter-clockwise) or - (clockwise).
Implies -Q+.
-F[l] Force input data to become polygons on output, i.e., close them explicitly if not already closed.
Optionally, append l to force line geometry.
-I[e|i] Determine the intersection locations between all pairs of polygons. Append i to only compute
internal (i.e., self-intersecting polygons) crossovers or e to only compute external (i.e., between
paris of polygons) crossovers [Default is both].
-Npfile[+a][+pstart][+r][+z] Determine if one (or all, with +a) points of each feature in the input data
are inside any of the polygons given in the pfile. If inside, then report which polygon it is; the
polygon ID is either taken from the aspatial value assigned to Z, the segment header (first -Z, then
-L are scanned), or it is assigned the running number that is initialized to start [0]. By default
the input segment that are found to be inside a polygon are written to stdout with the polygon ID
encoded in the segment header as -ZID. Alternatively, append +r to just report which polygon
contains a feature or +z to have the IDs added as an extra data column on output. Segments that
fail to be inside a polygon are not written out. If more than one polygon contains the same segment
we skip the second (and further) scenario.
-Q[[-|+]*unit*][+cmin[/max]][+h][+l][+p][+s[a|d]] Measure the area of all polygons or length of line
segments. Use -Q+h to append the area to each polygons segment header [Default simply writes
the area to stdout]. For polygons we also compute the centroid location while for line data we
compute the mid-point (half-length) position. Append a distance unit to select the unit used (see
UNITS). Note that the area will depend on the current setting of PROJ_ELLIPSOID; this should
be a recent ellipsoid to get accurate results. The centroid is computed using the mean of the 3-D
Cartesian vectors making up the polygon vertices, while the area is obtained via an equal-area
projection. For line lengths you may prepend -|+ to the unit and the calculation will use Flat
Earth or Geodesic algorithms, respectively [Default is great circle distances]. Normally, all input
segments will be be reflected on output. Use c to restrict processing to those whose length (or area
for polygons) fall inside the specified range set by min and max. If max is not set it defaults to
infinity. To sort the segments based on their lengths or area, use s and append a for ascending and
d for descending order [ascending]. By default, we consider open polygons as lines. Append +p
to close open polygons and thus consider all input as polygons, or append +l to consider all input
as lines, even if closed.
-R[unit]west/east/south/north[/zmin/zmax][r] west, east, south, and north specify the region of interest, 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 w/e/s/n. The two
shorthands -Rg and -Rd stand for global domain (0/360 and -180/+180 in longitude respectively,
with -90/+90 in latitude). Alternatively for grid creation, give Rcodelon/lat/nx/ny, where code is
a 2-character combination of L, C, R (for left, center, or right) and T, M, B for top, middle, or
bottom. e.g., BL for lower left. This indicates which point on a rectangular region the lon/lat coordinate refers to, and the grid dimensions nx and ny with grid spacings via -I is used to create
the corresponding region. Alternatively, specify the name of an existing grid file and the -R settings (and grid spacing, if applicable) are copied from the grid. Using -Runit expects projected
(Cartesian) coordinates compatible with chosen -J and we inversely project to determine actual
rectangular geographic region. For perspective view (-p), optionally append /zmin/zmax. In case
of perspective view (-p), a z-range (zmin, zmax) can be appended to indicate the third dimension.
This needs to be done only when using the -Jz option, not when using only the -p option. In the
latter case a perspective view of the plane is plotted, with no third dimension. Clips polygons to
the map region, including map boundary to the polygon as needed. The result is a closed polygon.
-Si|j|s|u Spatial processing of polygons. Choose from -Si which returns the intersection of polygons
1.23. gmtspatial
97
(closed), -Su which returns the union of polygons (closed), -Ss which will split polygons that
straddle the Dateline, and -Sj which will join polygons that were split by the Dateline. Note: Only
-Ss has been implemented.
-T[clippolygon] Truncate polygons against the specified polygon given, possibly resulting in open polygons. If no argument is given to -T we create a clipping polygon from -R which then is required.
Note that when the -R clipping is in effect we will also look for polygons of length 4 or 5 that
exactly match the -R clipping polygon.
-V[level] (more ...) Select verbosity level [c].
-bi[ncols][t] (more ...) Select native binary input. [Default is 2 input columns].
-bo[ncols][type] (more ...) Select native binary output. [Default is same as input].
-d[i|o]nodata (more ...) Replace input columns that equal nodata with NaN and do the reverse on output.
-f[i|o]colinfo (more ...) Specify data types of input and/or output columns.
-g[a]x|y|d|X|Y|D|[col]z[+|-]gap[u] (more ...) Determine data gaps and line breaks.
-h[i|o][n][+c][+d][+rremark][+rtitle] (more ...) Skip or produce header record(s).
-icols[l][sscale][ooffset][,...] (more ...) Select input columns (0 is first column).
-ocols[,...] (more ...) Select output columns (0 is first column).
-:[i|o] (more ...) Swap 1st and 2nd column on input and/or output.
-^ or just - Print a short message about the syntax of the command, then exits (NOTE: on Windows use
just -).
-+ or just + Print an extensive usage (help) message, including the explanation of any module-specific
option (but not the GMT common options), then exits.
-? or no arguments Print a complete usage (help) message, including the explanation of options, then
exits.
1.23.5 Units
For map distance unit, append unit d for arc degree, m for arc minute, and s for arc second, or e for
meter [Default], f for foot, k for km, M for statute mile, n for nautical mile, and u for US survey foot.
By default we compute such distances using a spherical approximation with great circles. Prepend - to
a distance (or the unit is no distance is given) to perform Flat Earth calculations (quicker but less
accurate) or prepend + to perform exact geodesic calculations (slower but more accurate).
98
1.23.7 Example
To turn all lines in the multisegment file lines.txt into closed polygons, run
gmt spatial lines.txt -F > polygons.txt
To compute the area of all geographic polygons in the multisegment file polygons.txt, run
gmt spatial polygons.txt -Q > areas.txt
Same data, but now orient all polygons to go counter-clockwise and write their areas to the segment
headers, run
gmt spatial polygons.txt -Q+h -E+ > areas.txt
To determine the areas of all the polygon segments in the file janmayen_land_full.txt, add this information to the segment headers, sort the segments from largest to smallest in area but only keep polygons
with area larger than 1000 sq. meters, run
gmt spatial -Qe+h+p+c1000+sd -V janmayen_land_full.txt > largest_pols.txt
To determine the intersections between the polygons A.txt and B.txt, run
gmt spatial A.txt B.txt -Ie > crossovers.txt
To truncate polygons A.txt against polygon B.txt, resulting in an open line segment, run
gmt gmtspatial A.txt -TB.txt > line.txt
1.23.8 Notes
OGR/GMT files are considered complete datasets and thus you cannot specify more than one at a given
time. This causes problems if you want to examine the intersections of two OGR/GMT files. The solution
is to convert them to regular datasets via gmtconvert and then run gmtspatial on the converted files.
1.24 gmtswitch
gmtswitch - Switching between different GMT versions
1.24.1 Synopsis
gmtswitch [ D | version ]
1.24. gmtswitch
99
1.24.2 Introduction
gmtswitch helps you modify your environment to allow for the switching back and forth between several installed GMT versions, in particular GMT 5 and versions from the GMT 4 series. It works by
maintaining a list of directories to GMT installations in a file in your home directory, then manipulates
a symbolic link to point to the GMT directory whose executables we wish to use [The Windows version
works a bit differently; see WINDOWS below].
1.24.5 Setup
If you have official versions installed then running gmtswitch the very first time will examine your hard
disk starting at / and look for directories with GMT4 or GMT5 in the name. This will fail to find the
subversion directories and possibly others you have placed elsewhere. The fastest way to get up and
running is this:
1. Edit/Create ~/.gmtversions and add the paths to all GMT installations you have or care to
consider. Each path goes on separate lines and points to the top dir of each distribution,
e.g., /Users/pwessel/UH/RESEARCH/PROJECTS/GMTdev/GMT4.5.7
2. In your .bashrc or .[t]csrh or wherever you are maintaining your PATH or path variable, remove any directories you have added that contain GMT, and add the new path
$HOME/this_gmt/bin (might be $home for csh users). Make sure this path appears before
any others that might contain a GMT installation, such as those used by package managers
(e.g., /sw/bin for fink, /opt/local/bin for Macports, etc.).
3. Make the new path take effect (quit/restart terminal, logout/login, etc).
4. cd to the most recent GMT directory where a gmtswitch version lives, and run gmtswitch
with no argument. Select one of the version from the menu.
5. If in csh you may have to say rehash afterwards.
6. Type psxy - and the synopsis should tell you that you got the correct version. You can now
run gmtswitch from anywhere; try it out and make sure that you can switch between the
versions.
1.24.6 Examples
To switch to GMT version 4.5.7 (assuming it was installed as such and not via a package manager), try
100
gmtswitch GMT4.5.7
To switch to the default (your top choice), do
gmtswitch D
Finally, to select from the menu, just run
gmtswitch
and pick the one you want.
1.24.7 Beware
GMT remembers where it was installed the first time and uses that dir to find the default GMT
share directory. If you move entire GMT installation after compilation then you may have to set
GMT_SHAREDIR to point to the top dir in order for things to work. It is best not to move things
after installation.
1.24.8 Windows
Under Windows use gmtswitch.bat which is a batch script that changes the Windows PATH variable so
that the BIN directory of the preferred version always comes first. To do that the batch works in two
alternative modes:
1 - Permanent mode
2 - Temporary mode
The permanent mode makes use of the free executable program EditPath to change the user path in
the registry. Its called permanent because the changes remains until ... next change. See
http://www.softpedia.com/get/Tweak/Registry-Tweak/EditPath.shtml
Of course the editpath.exe binary must be in your systems path as well. WARNING: The path change
will not be visible on the shell cmd where it was executed. For the change to be active you will need to
open a new cmd window.
The second mode is temporary because the path to the selected GMT binary dir is prepended to the
previous path via a shell command line. This modification disappears when the shell cmd window where
it was executes is deleted.
It is the user responsibility to set the contents of the G32_32 to G5_64 below to valid paths where the
binaries of the different GMT versions are installed Note that it is not mandatory to have all four of them
in you computer. For the ones you do not have just let them pointing to nothing e.g.,
set G4_64=
The permanent mode is the default one (but this can be changed. See edit section) To run in the temporary
mode just give a second argument (doesnt matter what)
Example usage to set a GMT5 64 bits permanent
gmtswitch g5_64
To temporary set a GMT4 32 bits do
gmtswitch g4_32 1
1.24. gmtswitch
101
1.25 gmtvector
gmtvector - Operations on Cartesian vectors in 2-D and 3-D
1.25.1 Synopsis
gmtvector [ tables ] [ -Am[conf ]|vector ] [ -C[i|o] ] [ -E ] [ -N ] [ -Svector ] [ -Ta|d|D|paz|r[arg|R|s|x]
] [ -V[level] ] [ -bbinary ] [ -dnodata ] [ -fflags ] [ -ggaps ] [ -hheaders ] [ -iflags ] [ -oflags ] [ -:[i|o] ]
Note: No space is allowed between the option flag and the associated arguments.
1.25.2 Description
gmtvector reads either (x, y), (x, y, z), (r, theta) or (lon, lat) [or (lat,lon); see -:] coordinates from the
first 2-3 columns on standard input [or one or more tables]. If -fg is selected and only two items are
read (i.e., lon, lat) then these coordinates are converted to Cartesian three-vectors on the unit sphere.
Otherwise we expect (r, theta) unless -Ci is in effect. If no file is found we expect a single vector to be
given as argument to -A; this argument will also be interpreted as an x/y[/z], lon/lat, or r/theta vector.
The input vectors (or the one provided via -A) are denoted the prime vector(s). Several standard vector
operations (angle between vectors, cross products, vector sums, and vector rotations) can be selected;
most require a single second vector, provided via -S. The output vectors will be converted back to (lon,
lat) or (r, theta) unless -Co is set which requests (x, y[, z]) Cartesian coordinates.
102
-N Normalize the resultant vectors prior to reporting the output [No normalization]. This only has an
effect if -Co is selected.
-S[vector] Specify a single, secondary vector in the same format as the first vector. Required by operations in -T that need two vectors (average, bisector, dot product, cross product, and sum).
-Ta|d|D|paz|s|r[arg|R|x] Specify the vector transformation of interest. Append a for average, b for the
pole of the two points bisector, d for dot product (use D to get angle in degrees between the
two vectors), paz for the pole to the great circle specified by input vector and the circles az (no
second vector used), s for vector sum, rpar for vector rotation (here, par is a single angle for 2-D
Cartesian data and lon/lat/angle for a 3-D rotation pole and angle), R will instead rotate the fixed
secondary vector by the rotations implied by the input records, and x for cross-product. If -T is
not given then no transformation takes place; the output is determined by other options such as
-A, -C, -E, and -N.
-V[level] (more ...) Select verbosity level [c].
-bi[ncols][t] (more ...) Select native binary input. [Default is 2 or 3 input columns].
-d[i|o]nodata (more ...) Replace input columns that equal nodata with NaN and do the reverse on output.
-f[i|o]colinfo (more ...) Specify data types of input and/or output columns.
-g[a]x|y|d|X|Y|D|[col]z[+|-]gap[u] (more ...) Determine data gaps and line breaks.
-h[i|o][n][+c][+d][+rremark][+rtitle] (more ...) Skip or produce header record(s).
-icols[l][sscale][ooffset][,...] (more ...) Select input columns (0 is first column).
-ocols[,...] (more ...) Select output columns (0 is first column).
-:[i|o] (more ...) Swap 1st and 2nd column on input and/or output.
-^ or just - Print a short message about the syntax of the command, then exits (NOTE: on Windows use
just -).
-+ or just + Print an extensive usage (help) message, including the explanation of any module-specific
option (but not the GMT common options), then exits.
-? or no arguments Print a complete usage (help) message, including the explanation of options, then
exits.
1.25.6 Examples
Suppose you have a file with lon, lat called points.txt. You want to compute the spherical angle between
each of these points and the location 133/34. Try
1.25. gmtvector
103
To rotate the same points 35 degrees around a pole at 133/34, and output Cartesian 3-D vectors, use
gmt vector points.txt -Tr133/34/35 -Co -fg > reconstructed.txt
To rotate the point 65/33 by all rotations given in file rots.txt, use
gmt vector rots.txt -TR -S64/33 -fg > reconstructed.txt
To compute the cross-product between the two Cartesian vectors 0.5/1/2 and 1/0/0.4, and normalizing
the result, try
gmt vector -A0.5/1/2 -Tx -S1/0/0.4 -N -C > cross.txt
To rotate the 2-D vector, given in polar form as r = 2 and theta = 35, by an angle of 120, try
gmt vector -A2/35 -Tr120 > rotated.txt
To find the mid-point along the great circle connecting the points 123/35 and -155/-30, use
gmt vector -A123/35 -S-155/-30 -Ta -fg > midpoint.txt
To find the mean location of the geographical points listed in points.txt, with its 99% confidence ellipse,
use
gmt vector points.txt -Am99 -fg > centroid.txt
To find the pole corresponding to the great circle that goes through the point -30/60 at an azimuth of 105
degrees, use
gmt vector -A-30/60 -Tp105 -fg > pole.txt
1.25.7 Rotations
For more advanced 3-D rotations as used in plate tectonic reconstructions, see the GMT spotter supplement.
1.26 gmtwhich
gmtwhich - Find full path to specified files
1.26.1 Synopsis
gmtwhich files [ -A ] [ -C ] [ -D ] [ -V[level] ]
Note: No space is allowed between the option flag and the associated arguments.
104
1.26.2 Description
gmtwhich reports the full paths to the files given on the command line. We look for the file in (1) the
current directory, (2) in $GMT_USERDIR (if defined), (3) in $GMT_DATADIR (if defined). If found
we print the full path name to the file, just the directory (see -D), or a confirmation (see -C). The
$GMT_USERDIR and $GMT_DATADIR environment variables can be colon-separated list of directories, and we search recursively down any directory that ends with / (i.e., /export/data is a single directory
whereas /export/data/ will be searched recursively.)
1.27 grd2cpt
grd2cpt - Make linear or histogram-equalized color palette table from grid
1.27.1 Synopsis
grd2cpt grid [ -A[+]transparency ] [ -Ccpt ] [ -D[i|o] ] [ -E[nlevels] ] [ -F[R|r|h|c ][+c]] [ -Gzlo/zhi ]
[ -I ] [ -Lminlimit/maxlimit ] [ -M ] [ -N ] [ -Q[i|o] ] [ -Rregion ] [ -Szstart/zstop/zinc ] [ -T-|+|_|= ] [
-V[level] ] [ -W ] [ -Z ]
Note: No space is allowed between the option flag and the associated arguments.
1.27. grd2cpt
105
1.27.2 Description
grd2cpt reads one or more grid files and writes a static color palette (CPT) file to standard output. The
CPT is based on an existing dynamic master CPT of your choice, and the mapping from data value
to colors is through the datas cumulative distribution function (CDF), so that the colors are histogram
equalized. Thus if the grid(s) and the resulting CPT are used in grdimage with a linear projection, the
colors will be uniformly distributed in area on the plot. Let z be the data values in the grid. Define
CDF(Z) = (# of z < Z) / (# of z in grid). (NaNs are ignored). These z-values are then normalized to the
master CPT and colors are sampled at the desired intervals.
The color palette includes three additional colors beyond the range of z-values. These are the background
color (B) assigned to values lower than the lowest z-value, the foreground color (F) assigned to values
higher than the highest z-value, and the NaN color (N) painted wherever values are undefined. For color
tables beyond the standard GMT offerings, visit cpt-city: http://soliton.vm.bytemark.co.uk/pub/cpt-city/.
If the master CPT includes B, F, and N entries, these will be copied into the new master file. If not, the
parameters COLOR_BACKGROUND, COLOR_FOREGROUND, and COLOR_NAN from the gmt.conf
file or the command line will be used. This default behavior can be overruled using the options -D, -M
or -N.
The color model (RGB, HSV or CMYK) of the palette created by makecpt will be the same as specified
in the header of the master CPT. When there is no COLOR_MODEL entry in the master CPT, the
COLOR_MODEL specified in the gmt.conf file or on the command line will be used.
106
-Gzlo/zhi Truncate the incoming CPT so that the lowest and highest z-levels are to zlo and zhi. If one of
these equal NaN then we leave that end of the CPT alone. The truncation takes place before any
resampling.
-I Reverses the sense of color progression in the master CPT. Also exchanges the foreground and
background colors, including those specified by the parameters COLOR_BACKGROUND and
COLOR_FOREGROUND.
-Lminlimit/maxlimit Limit range of CPT to minlimit/maxlimit, and dont count data outside this range
when estimating CDF(Z). [Default uses min and max of data.]
-M Overrule background, foreground, and NaN colors specified in the master CPT with the values of
the parameters COLOR_BACKGROUND, COLOR_FOREGROUND, and COLOR_NAN specified in the gmt.conf file or on the command line. When combined with -D, only COLOR_NAN is
considered.
-N Do not write out the background, foreground, and NaN-color fields [Default will write them].
-Q[i|o] Selects a logarithmic interpolation scheme [Default is linear]. -Qi expects input z-values to be
log10(z), assigns colors, and writes out z [Default]. -Qo takes log10(z) first, assigns colors, and
writes out z.
-R[unit]xmin/xmax/ymin/ymax[r] (more ...) Specify the region of interest.
-Szstart/zstop/zinc or -Sn Set steps in CPT. Calculate entries in CPT from zstart to zstop in steps of
(zinc). Default chooses arbitrary values by a crazy scheme based on equidistant values for a Gaussian CDF. Use -Sn to select n points from such a cumulative normal distribution [11].
-T-|+|_|= Force the color table to be symmetric about zero (from -R to +R). Append flag to set the range
R: - for R =|zmin|, + for R = |zmax|, _ for R = min(|zmin|, |zmax|), or = for R = max(|zmin|, |zmax|).
-V Verbose operation. This will write CDF(Z) estimates to stderr. [Default is silent.]
-W Do not interpolate the input color table but pick the output colors starting at the beginning of the
map. This is particularly useful in combination with a categorical color table. Cannot be used in
combination with -Z.
-Z Will create a continuous color palette. [Default is discontinuous, i.e., constant color intervals]
-^ or just - Print a short message about the syntax of the command, then exits (NOTE: on Windows use
just -).
-+ or just + Print an extensive usage (help) message, including the explanation of any module-specific
option (but not the GMT common options), then exits.
-? or no arguments Print a complete usage (help) message, including the explanation of options, then
exits.
1.27. grd2cpt
107
1.27.8 Examples
Sometimes you dont want to make a CPT (yet) but would find it helpful to know that 90% of your data
lie between z1 and z2, something you cannot learn from grdinfo. So you can do this to see some points
on the CDF(Z) curve (use -V option to see more):
gmt grd2cpt mydata.nc -V > /dev/null
To make a CPT with entries from 0 to 200 in steps of 20, and ignore data below zero in computing
CDF(Z), and use the built-in master cpt file relief, run
gmt grd2cpt mydata.nc -Crelief -L0/10000 -S0/200/20 > mydata.cpt
1.28 grd2rgb
grd2rgb - Write r/g/b grid files from a grid file, a raw RGB file, or SUN rasterfile
1.28.1 Synopsis
grd2rgb infile -Gtemplate [ -Ccpt ] [ -Ixinc[m|s][/yinc[m|s]] ] [ -Llayer ] -Rregion -V[level] [ Wwidth/height[/n_bytes] ] [ -r ]
Note: No space is allowed between the option flag and the associated arguments.
108
1.28.2 Description
grd2rgb reads one of three types of input files: (1) A Sun 8-, 24-, or 32-bit raster file; we the write out
the red, green, and blue components (0-255 range) to separate grid files. Since the raster file header is
limited you may use the -R, -I, -r options to set a complete header record [Default is simply based on
the number of rows and columns]. (2) A binary 2-D grid file; we then convert the z-values to red, green,
blue via the provided CPT. Optionally, only write out one of the r, g, b, layers. (3) A RGB or RGBA
raw raster file. Since raw rasterfiles have no header, you have to give the image dimensions via the -W
option.
1.28. grd2rgb
109
-? or no arguments Print a complete usage (help) message, including the explanation of options, then
exits.
1.28.5 Examples
To use the color palette topo.cpt to create r, g, b component grids from hawaii_grv.nc file, use
gmt grd2rgb hawaii_grv.nc -Ctopo.cpt -Ghawaii_grv_%c.nc
To output the red component from the Sun raster radiation.ras file, use
gmt grd2rgb radiation.ras -Lr -Gcomp_%c.nc
1.29 grd2xyz
grd2xyz - Convert grid file to data table
1.29.1 Synopsis
grd2xyz grid [ -C[f|i] ] [ -Rregion ] [ -V[level] ] [ -W[weight] ] [ -Z[flags] ] [ -bobinary ] [ -dnodata ] [
-fflags ] [ -ho[n] ] [ -oflags ] [ -sflags ]
Note: No space is allowed between the option flag and the associated arguments.
1.29.2 Description
grd2xyz reads one or more binary 2-D grid files and writes out xyz-triplets in ASCII [or binary]
format to standard output. Modify the precision of the ASCII output format by editing the FORMAT_FLOAT_OUT parameter in your gmt.conf 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) coordinates; see -Z below.
110
-R[unit]xmin/xmax/ymin/ymax[r] (more ...) Specify the region of interest. Using the -R option will
select a subsection of the grid. If this subsection exceeds the boundaries of the grid, only the
common region will be output.
-V[level] (more ...) Select verbosity level [c].
-W[weight] Write out x,y,z,w, where w is the supplied weight (or 1 if not supplied) [Default writes x,y,z
only].
-Z[flags] 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 written 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 of a single item per record
c int8_t, signed 1-byte character
u uint8_t, unsigned 1-byte character
h int16_t, short 2-byte integer
H uint16_t, unsigned short 2-byte integer
i int32_t, 4-byte integer
I uint32_t, unsigned 4-byte integer
l int64_t, long (8-byte) integer
L uint64_t, unsigned long (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[ncols][type] (more ...) Select native binary output. [Default is 3]. This option only applies to xyz
output; see -Z for z table output.
-d[i|o]nodata (more ...) Replace input columns that equal nodata with NaN and do the reverse on output.
-f[i|o]colinfo (more ...) Specify data types of input and/or output columns. See also TIME COORDINATES below. -h Output 1 header record based on information in the first grid file header. Ignored
if binary output is selected. [Default is no header].
-ocols[,...] (more ...) Select output columns (0 is first column).
-s[cols][a|r] (more ...) Set handling of NaN records.
-^ or just - Print a short message about the syntax of the command, then exits (NOTE: on Windows use
just -).
1.29. grd2xyz
111
-+ or just + Print an extensive usage (help) message, including the explanation of any module-specific
option (but not the GMT common options), then exits.
-? or no arguments Print a complete usage (help) message, including the explanation of options, then
exits.
1.29.8 Examples
To edit individual values in the 5 by 5 hawaii_grv.nc file, dump the .nc to ASCII:
gmt grd2xyz hawaii_grv.nc > hawaii_grv.xyz
To write a single precision binary file without the x,y positions from the file raw_data.nc file, using
scanline orientation, run
gmt grd2xyz raw_data.nc -ZTLf > hawaii_grv.b
1.30 grdblend
grdblend - Blend several partially over-lapping grids into one large grid
112
1.30.1 Synopsis
grdblend [ blendfile | grid1 grid2 ... ] -Goutgrid [ -Iincrement ] [ -Rregion ] [ -Cf|l|o|u ] [ -Nnodata ] [
-Q ] [ -Zscale ] [ -V[level] ] [ -W[z] ] [ -fflags ] [ -nflags ] [ -r ]
Note: No space is allowed between the option flag and the associated arguments.
1.30.2 Description
grdblend reads a listing of grid files and blend parameters and creates a binary grid file by blending
the other grids using cosine-taper weights. grdblend will report if some of the nodes are not filled in
with data. Such unconstrained nodes are set to a value specified by the user [Default is NaN]. Nodes with
more than one value will be set to the weighted average value. Any input grid that does not share the final
output grids node registration and grid spacing will automatically be resampled via calls to grdsample.
Note: Due to the row-by-row i/o nature of operations in grdblend we only support the netCDF and native
binary grid formats for both input and output.
113
than one grid file to blend and you wish (a) all input grids to have the same weight (1) and (b) all
grids should use their actual region as the interior region, then you may simply list all the grids on
the command line instead of providing a blendfile. You must specify at least 2 input grids for this
mechanism to work. Any grid that is not co-registered with the desired output layout implied by
-R, -I (and -r) will first be resampled via grdsample. Also, grids that are not in netCDF or native
binary format will first be reformatted via grdconvert.
-C Clobber mode: Instead of blending, simply pick the value of one of the grids that covers a node.
Select from the following modes: f for the first grid to visit a node; o for the last grid to visit a
node; l for the grid with the lowest value, and u for the grid with the uppermost value. For modes
f and o the ordering of grids in the blendfile will dictate which grid contributes to the final result.
Weights and cosine tapering are not considered when clobber mode is active.
-Nnodata No data. Set nodes with no input grid to this value [Default is NaN].
-Q Create a header-less grid file suitable for use with grdraster. Requires that the output grid file is a
native format (i.e., not netCDF).
-V[level] (more ...) Select verbosity level [c].
-W[z] Do not blend, just output the weights used for each node [Default makes the blend]. Append z to
write the weight*z sum instead.
-Zscale Scale output values by scale before writing to file. [1].
-f[i|o]colinfo (more ...) Specify data types of input and/or output columns.
-n[b|c|l|n][+a][+bBC][+c][+tthreshold] (more ...) Select interpolation mode for grids.
-r (more ...) Set pixel node registration [gridline].
-^ or just - Print a short message about the syntax of the command, then exits (NOTE: on Windows use
just -).
-+ or just + Print an extensive usage (help) message, including the explanation of any module-specific
option (but not the GMT common options), then exits.
-? or no arguments Print a complete usage (help) message, including the explanation of options, then
exits.
114
1.30.7 Tapering
While the weights computed are tapered from 1 to 0, we are computing weighted averages, so if there is
only a single grid given then the weighted output will be identical to the input. If you are looking for a
way to taper your data grid, see grdmaths TAPER operator.
1.30.8 Examples
To create a grid file from the four grid files piece_?.nc, giving them each the different weights, make the
blendfile like this
piece_1.nc
piece_2.nc
piece_3.nc
piece_4.nc
-R<subregion_1>
-R<subregion_2>
-R<subregion_3>
-R<subregion_4>
1
1.5
0.9
1
Then run
gmt grdblend blend.job -Gblend.nc -R<full_region> -I<dx/dy> -V
To blend all the grids called MB_*.nc given them all equal weight, try
gmt grdblend MB_*.nc -Gblend.nc -R<full_region> -I<dx/dy> -V
1.31 grdclip
grdclip - Clip the range of grid values
1.31. grdclip
115
1.31.1 Synopsis
grdclip ingrid -Goutgrid [ -Rregion ] [ -Sahigh/above ] [ -Sblow/below ] [ -Silow/high/between ] [
-Srold/new ] [ -V[level] ]
Note: No space is allowed between the option flag and the associated arguments.
1.31.2 Description
grdclip will set values < low to below and/or values > high to above. You can also specify one or more
intervals where all values should be set to IT(between), or replace individual values. Such operations
are useful when you want all of a continent or an ocean to fall into one color or gray shade in image
processing, when clipping of the range of data values is required, or for reclassification of data values.
above, below, between, old and new can be any number or even NaN (Not a Number). You must choose
at least one of the -S options. Use -R to only extract a subset of the ingrid file.
1.31.6 Examples
To set all values > 70 to NaN and all values < 0 to 0 in file data.nc:
gmt grdclip data.nc -Gnew_data.nc -Sa70/NaN -Sb0/0 -V
To reclassify all values in the 25-30 range to 99, those in 35-39 to 55, exchange 17 for 11 and all values
< 10 to 0 in file classes.nc, try
gmt grdclip classes.nc -Gnew_classes.nc -Si25/30/99 -Si35/39/55 -Sr17/11 -Sb10/0 V
1.32 grdcontour
grdcontour - Make contour map using a grid
1.32.1 Synopsis
grdcontour grid -C[+]cont_int|cpt -Jparameters [ -A[-|[+]annot_int][labelinfo] ] [ -B[p|s]parameters
] [ -D<template> ] [ -F[l|r] ] [ -G[d|f|n|l|L|x|X]params ] [ -Jz|Zparameters ] [ -K ] [ -Llow/high
] [ -O ] [ -P ] [ -Qcut ] [ -Rwest/east/south/north[/zmin/zmax][r] ] [ -Ssmoothfactor ] [ -T[+|][+dgap[/length]][+l[labels]] ] [ -U[stamp] ] [ -V[level] ] [ -W[type]pen ][+c[l|f]] [ -Xx_offset ] [ Yy_offset ] [ -Z[factor[/shift]][p] ] [ -bobinary ] [ -ccopies ] [ -donodata ] [ -ho[n] ] [ -pflags ] [ -ttransp
]
Note: No space is allowed between the option flag and the associated arguments.
1.32.2 Description
grdcontour reads a 2-D grid file and produces a contour map by tracing each contour through the grid.
PostScript code is generated and sent to standard output. Various options that affect the plotting are
available. Alternatively, the x/y/z positions of the contour lines may be saved to one or more output files
(or stdout) and no plot is produced.
1.32. grdcontour
117
2. If cont_int is a file but not a CPT, it is expected to contain contour levels in column 1 and
a C(ontour) OR A(nnotate) in col 2. The levels marked C (or c) are contoured, the levels
marked A (or a) are contoured and annotated. Optionally, a third column may be present and
contain the fixed annotation angle for this contour level.
3. If no file is found, then cont_int is interpreted as a constant contour interval. However, if
prepended with the + sign the cont_int is taken as meaning draw that single contour. The -A
option offers the same possibility so they may be used together to plot a single annotated
contour and another single non-annotated contour, as in ... -A+10 -C+5 that plots an annotated 10 contour and an non-annotated 5 contour. If -A is set and -C is not, then the contour
interval is set equal to the specified annotation interval.
If a file is given and -T is set, then only contours marked with upper case C or A will have tickmarks. In all cases the contour values have the same units as the grid.
-Jparameters (more ...) Select map projection.
+rmin_rad Will not place labels where the contourss radius of curvature is less than
min_rad [Default is 0].
+t[file] Saves contour label x, y, angle, and text to file [Contour_labels.txt].
+uunit Appends unit to all contour labels. [Default is no unit]. If z is appended we use the
z-unit from the grdfile.
+v Specifies curved labels following the contour [Default is straight labels].
+w Specifies how many (x,y) points will be used to estimate label angles [automatic].
+=prefix Prepends prefix to all contour labels. [Default is no prefix].
-B[p|s]parameters (more ...) Set map boundary intervals.
-D<template> Dump contours as data line segments; no plotting takes place. Append filename template
which may contain C-format specifiers. If no filename template is given we write all lines to
stdout. If filename has no specifiers then we write all lines to a single file. If a float format (e.g.,
%6.2f) is found we substitute the contour z-value. If an integer format (e.g., %06d) is found we
substitute a running segment count. If an char format (%c) is found we substitute C or O for closed
and open contours. The 1-3 specifiers may be combined and appear in any order to produce the
the desired number of output files (e.g., just %c gives two files, just %f would. separate segments
into one file per contour level, and %d would write all segments. to individual files; see manual
page for more examples.
-F[l|r] Force dumped contours to be oriented so that higher z-values are to the left (-Fl [Default]) or
right (-Fr) as we move along the contour [Default is arbitrary orientation]. Requires -D.
-G[d|f|n|l|L|x|X]params
The required argument controls the placement of labels along the quoted lines. Choose
among five controlling algorithms:
ddist[c|i|p] or Ddist[d|e|f|k|m|M|n|s] For lower case d, give distances between labels on
the plot in your preferred measurement unit c (cm), i (inch), or p (points), while for
upper case D, specify distances in map units and append the unit; choose among e
(m), f (foot), k (km), M (mile), n (nautical mile) or u (US survey foot), and d (arc
degree), m (arc minute), or s (arc second). [Default is 10c or 4i]. As an option, you
can append /fraction which is used to place the very first label for each contour when
the cumulative along-contour distance equals fraction * dist [0.25].
fffile.d Reads the ASCII file ffile.d and places labels at locations in the file that matches
locations along the quoted lines. Inexact matches and points outside the region are
skipped.
l|Lline1[,line2,...] Give start and stop coordinates for one or more comma-separated
straight line segments. Labels will be placed where these lines intersect the quoted
lines. The format of each line specification is start/stop, where start and stop are either a specified point lon/lat or a 2-character XY key that uses the justification format
employed in pstext to indicate a point on the map, given as [LCR][BMT]. In addition,
you can use Z-, Z+ to mean the global minimum and maximum locations in the grid.
L will interpret the point pairs as defining great circles [Default is straight line].
nn_label Specifies the number of equidistant labels for quoted lines line [1]. Upper case N
starts labeling exactly at the start of the line [Default centers them along the line]. N-1
places one justified label at start, while N+1 places one justified label at the end of
1.32. grdcontour
119
120
1.32.7 Examples
To contour the file hawaii_grav.nc every 25 mGal on a Mercator map at 0.5 inch/degree, annotate every
50 mGal (using fontsize = 10p), using 1 degree tickmarks, and draw 30 minute gridlines:
gmt grdcontour hawaii_grav.nc -Jm0.5i -C25 -A50+f10p -B1g30m > hawaii_grav.ps
To contour the file image.nc using the levels in the file cont.d on a linear projection at 0.1 cm/x-unit
and 50 cm/y-unit, using 20 (x) and 0.1 (y) tickmarks, smooth the contours a bit, use RMS Misfit as
plot-title, use a thick red pen for annotated contours, and a thin, dashed, blue pen for the rest, and send
the output to the default printer:
gmt grdcontour image.nc -Jx0.1c/50.0c -Ccont.d -S4 -Bx20 -By0.1 \
-B+t"RMS Misfit" -Wathick,red -Wcthinnest,blue,- | lp
The labeling of local highs and lows may plot outside the innermost contour since only the mean value
of the contour coordinates is used to position the label.
1.32. grdcontour
121
To save the smoothed 100-m contour lines in topo.nc and separate them into two multisegment files:
contours_C.txt for closed and contours_O.txt for open contours, try
gmt grdcontour topo.nc -C100 -S4 -Dcontours_%c.txt
1.33 grdconvert
grdconvert - Convert between different grid formats
1.33.1 Synopsis
grdconvert ingrdfile[=id[/scale/offset[/NaNvalue]]] outgrdfile[=id[/scale/offset[/NaNvalue]][:driver[/datatype]]]
[ -N ] [ -Rregion ] [ -V[level] ] [ -fflags ]
Note: No space is allowed between the option flag and the associated arguments.
1.33.2 Description
grdconvert reads a grid file in one format and writes it out using another format. As an option the user
may select a subset of the data to be written and to specify scaling, translation, and NaN-value.
offset of packed integer grids (=id/a is a shorthand for =id/a/a). When id=gd, the file will be
saved using the GDAL library. Append the format :driver and optionally the output datatype. The
driver names are those used by GDAL itself (e.g., netCDF, GTiFF, etc.), and the data type is one of
u8|u16|i16|u32|i32|float32, where i and u denote signed and unsigned integers respectively. The
default type is float32. Note also that both driver names and data types are case insensitive. See
Section grid-file-format of the GMT Technical Reference and Cookbook for more information.
Consider setting IO_NC4_DEFLATION_LEVEL to reduce file size and to further increase
read/write performance. Especially when working with subsets of global grids, masks, and grids
with repeating grid values, the improvement is usually significant.
1.33. grdconvert
123
ID
nb
ns
ni
nf
nd
cb
cs
ci
cf
cd
bm
bb
bs
bi
bf
bd
rb
rf
sf
sd
af
ei
ef
gd
Explanation
GMT netCDF format (8-bit integer, COARDS, CF-1.5)
GMT netCDF format (16-bit integer, COARDS, CF-1.5)
GMT netCDF format (32-bit integer, COARDS, CF-1.5)
GMT netCDF format (32-bit float, COARDS, CF-1.5)
GMT netCDF format (64-bit float, COARDS, CF-1.5)
GMT netCDF format (8-bit integer, deprecated)
GMT netCDF format (16-bit integer, deprecated)
GMT netCDF format (32-bit integer, deprecated)
GMT netCDF format (32-bit float, deprecated)
GMT netCDF format (64-bit float, deprecated)
GMT native, C-binary format (bit-mask)
GMT native, C-binary format (8-bit integer)
GMT native, C-binary format (16-bit integer)
GMT native, C-binary format (32-bit integer)
GMT native, C-binary format (32-bit float)
GMT native, C-binary format (64-bit float)
SUN rasterfile format (8-bit standard)
GEODAS grid format GRD98 (NGDC)
Golden Software Surfer format 6 (32-bit float)
Golden Software Surfer format 7 (64-bit float, read-only)
Atlantic Geoscience Center format AGC (32-bit float)
ESRI Arc/Info ASCII Grid Interchange format (ASCII integer)
ESRI Arc/Info ASCII Grid Interchange format (ASCII float)
Import/export through GDAL
124
Since question marks, brackets and parentheses have special meanings on the command line, escape
these meanings by placing the full filename and suffix between quotes.
1.33.9 Examples
To extract the second layer from a 3-dimensional grid named temp from a COARDS-compliant netCDF
file climate.nc:
gmt grdconvert climate.nc?temp[1] temp.nc -V
To create a 4-byte native floating point grid from the COARDS-compliant netCDF file data.nc:
gmt grdconvert data.nc ras_data.b4=bf -V
To make a 2-byte short integer file, scale it by 10, subtract 32000, setting NaNs to -9999, do
gmt grdconvert values.nc shorts.i2=bs/10/-32000/-9999 -V
To create a Sun standard 8-bit rasterfile for a subset of the data file image.nc, assuming the range in
image.nc is 0-1 and we need 0-255, run
gmt grdconvert image.nc -R-60/-40/-40/-30 image.ras8=rb/255/0 -V
To creat a dumb file saved as a 32 bits float GeoTiff using GDAL, run
gmt grdmath -Rd -I10 X Y MUL = lixo.tiff=gd:GTiff
1.33. grdconvert
125
1.34 grdcut
grdcut - Extract subregion from a grid
1.34.1 Synopsis
grdcut ingrid -Goutgrid -Rregion [ -N[nodata] ] [ -S[n]lon/lat/radius[unit] ] [ -V[level] ] [ Z[n|r]min/max ] [ -fflags ]
Note: No space is allowed between the option flag and the associated arguments.
1.34.2 Description
grdcut will produce a new outgrid file which is a subregion of ingrid. The subregion is specified with
-R as in other programs; the specified range must not exceed the range of ingrid (but see -N). If in doubt,
run grdinfo to check range. Alternatively, define the subregion indirectly via a range check on the node
values or via distances from a given point. Complementary to grdcut there is grdpaste, which will join
together two grid files along a common edge.
-^ or just - Print a short message about the syntax of the command, then exits (NOTE: on Windows use
just -).
-+ or just + Print an extensive usage (help) message, including the explanation of any module-specific
option (but not the GMT common options), then exits.
-? or no arguments Print a complete usage (help) message, including the explanation of options, then
exits.
1.34.5 Units
For map distance unit, append unit d for arc degree, m for arc minute, and s for arc second, or e for
meter [Default], f for foot, k for km, M for statute mile, n for nautical mile, and u for US survey foot.
By default we compute such distances using a spherical approximation with great circles. Prepend - to
a distance (or the unit is no distance is given) to perform Flat Earth calculations (quicker but less
accurate) or prepend + to perform exact geodesic calculations (slower but more accurate).
1.34.8 Examples
Suppose you have used surface to grid ship gravity in the region between 148E - 162E and 8N - 32N,
and you do not trust the gridding near the edges, so you want to keep only the area between 150E - 160E
and 10N - 30N, then:
gmt grdcut grav_148_162_8_32.nc -Ggrav_150_160_10_30.nc -R150/160/10/30 -V
To return the subregion of a grid such that any boundary strips where all values are entirely above 0 are
excluded, try
gmt grdcut bathy.nc -Gtrimmed_bathy.nc -Z-/0 -V
To return the subregion of a grid that contains all nodes within a distance of 500 km from the point 45,30
try
gmt grdcut bathy.nc -Gsubset_bathy.nc -S45/30/500k -V
1.34. grdcut
127
1.35 grdedit
grdedit - Modify header or content of a grid
1.35.1 Synopsis
grdedit grid [ -A ] [ -C ] [ -Dxname/yname/zname/scale/offset/invalid/title/remark ] [ -E[a|h|l|r|t|v] ] [
-Goutgrid ] [ -Jparameters ] [ -Ntable ] [ -Rregion ] [ -S ] [ -T ] [ -V[level] ] [ -bibinary ] [ -dinodata ]
[ -fflags ] [ -:[i|o] ]
Note: No space is allowed between the option flag and the associated arguments.
1.35.2 Description
grdedit reads the header information in a binary 2-D grid file and replaces the information with values
provided on the command line [if any]. As an option, global, geographical grids (with 360 degrees
longitude range) can be rotated in the east-west direction, and individual nodal values can be replaced
from a table of x, y, z values. grdedit only operates on files containing a grid header. Note: If it is
important to retain the original data you should use -G to save the modified grid to a new file.
128
clockwise (right), -Et will transpose the grid [Default], -Ev will flip the grid vertically (top-tobottom). Incompatible with the other options (except -G).
-Goutgrid Normally, grdedit will overwrite the existing grid with the modified grid. Use -G to write the
modified grid to the file outgrid instead.
-Jparameters (more ...) Select map projection. Use the -J syntax to save the georeferencing info as
CF-1 compliant metadata in netCDF grids. This metadata will be recognized by GDAL.
-Ntable Read the ASCII (or binary; see -bi) file table and replace the corresponding nodal values in the
grid with these x,y,z values.
-R[unit]xmin/xmax/ymin/ymax[r] (more ...) Specify the region of interest. The new w/e/s/n values will
replace those in the grid, and the x_inc, y_inc values are adjusted, if necessary.
-S For global, geographical grids only. Grid values will be shifted longitudinally according to the new
borders given in -R.
-T Make necessary changes in the header to convert a gridline-registered grid to a pixel-registered grid,
or vice-versa. Basically, gridline-registered grids will have their domain extended by half the
x- and y-increments whereas pixel-registered grids will have their domain shrunk by the same
amount.
-V[level] (more ...) Select verbosity level [c].
-bi[ncols][t] (more ...) Select native binary input. [Default is 3 input columns].
-dinodata (more ...) Replace input columns that equal nodata with NaN.
-f[i|o]colinfo (more ...) Specify data types of input and/or output columns.
-h[i|o][n][+c][+d][+rremark][+rtitle] (more ...) Skip or produce header record(s).
-^ or just - Print a short message about the syntax of the command, then exits (NOTE: on Windows use
just -).
-+ or just + Print an extensive usage (help) message, including the explanation of any module-specific
option (but not the GMT common options), then exits.
-? or no arguments Print a complete usage (help) message, including the explanation of options, then
exits.
1.35. grdedit
129
1.35.7 Examples
Let us assume the file data.nc covers the area 300/310/10/30. We want to change the boundaries from
geodetic longitudes to geographic and put a new title in the header. We accomplish this by
gmt grdedit data.nc -R-60/-50/10/30 -D//////"Gravity Anomalies"
The grid world.nc has the limits 0/360/-72/72. To shift the data so that the limits would be -180/180/72/72, use
gmt grdedit world.nc -R-180/180/-72/72 -S
The file junk.nc was created prior to GMT 3.1 with incompatible -R and -I arguments. To reset the xand y-increments we run
gmt grdedit junk.nc -A
The file junk.nc was created prior to GMT 4.1.3 and does not contain the required information to indicate
that the grid is geographic. To add this information, run
gmt grdedit junk.nc -fg
To rotate the grid oblique.nc 90 degrees counter-clockwise and write out the rotated grid to a new file,
run
gmt grdedit oblique.nc -El -Goblique_rot.nc
1.36 grdfft
grdfft - Mathematical operations on grids in the wavenumber (or frequency) domain
1.36.1 Synopsis
grdfft ingrid [ ingrid2 ] [ -Goutfile|table ] [ -Aazimuth ] [ -Czlevel ] [ -D[scale|g] ] [ -E[r|x|y][w[k]][n]
] [ -F[r|x|y]params ] [ -I[scale|g] ] [ -Nparams ] [ -Sscale ] [ -V[level] ] [ -fg ]
Note: No space is allowed between the option flag and the associated arguments.
1.36.2 Description
grdfft will take the 2-D forward Fast Fourier Transform and perform one or more mathematical operations in the frequency domain before transforming back to the space domain. An option is provided to
scale the data before writing the new values to an output file. The horizontal dimensions of the grid are
assumed to be in meters. Geographical grids may be used by specifying the -fg option that scales degrees
to meters. If you have grids with dimensions in km, you could change this to meters using grdedit or
scale the output with grdmath.
130
131
-Goutfile|table Filename for output netCDF grid file OR 1-D data table (see -E). This is optional for -E
(spectrum written to stdout) but mandatory for all other options that require a grid output.
-I[scale|g] Integrate the field, i.e., compute integral_over_z (field * dz). This is equivalent to divide by
kr in the frequency domain (kr is radial wave number). Append a scale to divide by (kr * scale)
instead. Alternatively, append g to indicate that your data set is gravity anomalies in mGal and
output should be geoid heights in meters. [Default is no scale].
-N[f|q|s|nx/ny][+a|[+d|h|l][+e|n|m][+twidth][+w[suffix]][+z[p]] Choose or inquire about suitable grid
dimensions for FFT and set optional parameters. Control the FFT dimension:
-Nf will force the FFT to use the actual dimensions of the data.
-Nq will inQuire about more suitable dimensions, report those, then continue.
-Ns will present a list of optional dimensions, then exit.
-Nnx/ny will do FFT on array size nx/ny (must be >= grid file size). Default chooses
dimensions >= data which optimize speed and accuracy of FFT. If FFT dimensions >
grid file dimensions, data are extended and tapered to zero.
Control detrending of data: Append modifiers for removing a linear trend:
+d: Detrend data, i.e. remove best-fitting linear trend [Default].
+a: Only remove mean value.
+h: Only remove mid value, i.e. 0.5 * (max + min).
+l: Leave data alone.
Control extension and tapering of data: Use modifiers to control how the extension and tapering
are to be performed:
+e extends the grid by imposing edge-point symmetry [Default],
+m extends the grid by imposing edge mirror symmetry
+n turns off data extension.
Tapering is performed from the data edge to the FFT grid edge [100%]. Change this
percentage via +twidth. When +n is in effect, the tapering is applied instead to the data
margins as no extension is available [0%].
Control writing of temporary results: For detailed investigation you can write the intermediate
grid being passed to the forward FFT; this is likely to have been detrended, extended by pointsymmetry along all edges, and tapered. Append +w[suffix] from which output file name(s) will be
created (i.e., ingrid_prefix.ext) [tapered], where ext is your file extension. Finally, you may save
the complex grid produced by the forward FFT by appending +z. By default we write the real and
imaginary components to ingrid_real.ext and ingrid_imag.ext. Append p to save instead the polar
form of magnitude and phase to files ingrid_mag.ext and ingrid_phase.ext.
-Sscale Multiply each element by scale in the space domain (after the frequency domain operations).
[Default is 1.0].
-V[level] (more ...) Select verbosity level [c].
-fg Geographic grids (dimensions of longitude, latitude) will be converted to meters via a Flat Earth
approximation using the current ellipsoid parameters.
-^ or just - Print a short message about the syntax of the command, then exits (NOTE: on Windows use
just -).
132
-+ or just + Print an extensive usage (help) message, including the explanation of any module-specific
option (but not the GMT common options), then exits.
-? or no arguments Print a complete usage (help) message, including the explanation of options, then
exits.
1.36.7 Considerations
netCDF COARDS grids will automatically be recognized as geographic. For other grids geographical
grids were you want to convert degrees into meters, select -fg. If the data are close to either pole, you
should consider projecting the grid file onto a rectangular coordinate system using grdproject
1.36.9 Examples
To upward continue the sea-level magnetic anomalies in the file mag_0.nc to a level 800 m above
sealevel:
gmt grdfft mag_0.nc -C800 -V -Gmag_800.nc
To transform geoid heights in m (geoid.nc) on a geographical grid to free-air gravity anomalies in mGal:
gmt grdfft geoid.nc -Dg -V -Ggrav.nc
To transform gravity anomalies in mGal (faa.nc) to deflections of the vertical (in micro-radians) in the
038 direction, we must first integrate gravity to get geoid, then take the directional derivative, and finally
scale radians to micro-radians:
1.36. grdfft
133
Second vertical derivatives of gravity anomalies are related to the curvature of the field. We can compute
these as mGal/m^2 by differentiating twice:
gmt grdfft gravity.nc -D -D -V -Ggrav_2nd_derivative.nc
To compute cross-spectral estimates for co-registered bathymetry and gravity grids, and report result as
functions of wavelengths in km, try
gmt grdfft bathymetry.nc gravity.grd -Ewk -fg -V > cross_spectra.txt
To examine the pre-FFT grid after detrending, point-symmetry reflection, and tapering has been applied,
as well as saving the real and imaginary components of the raw spectrum of the data in topo.nc, try
gmt grdfft topo.nc -N+w+z -fg -V
You can now make plots of the data in topo_taper.nc, topo_real.nc, and topo_imag.nc.
1.37 grdfilter
grdfilter - Filter a grid in the space (or time) domain
1.37.1 Synopsis
grdfilter ingrid -Ddistance_flag -Fxwidth[/width2][modifiers] -Goutgrid [ -Iincrement ] [ -Ni|p|r ] [
-Rregion ] [ -T ] [ -V[level] ] [ -fflags ]
Note: No space is allowed between the option flag and the associated arguments.
1.37.2 Description
grdfilter will filter a grid file in the time domain using one of the selected convolution or non-convolution
isotropic or rectangular filters and compute distances using Cartesian or Spherical geometries. The output grid file can optionally be generated as a sub-region of the input (via -R) and/or with new increment
(via -I) or registration (via -T). In this way, one may have extra space in the input data so that the
edges will not be used and the output can be within one half-width of the input edges. If the filter is
low-pass, then the output may be less frequently sampled than the input.
134
-Ddistance_flag Distance flag tells how grid (x,y) relates to filter width as follows:
flag = p: grid (px,py) with width an odd number of pixels; Cartesian distances.
flag = 0: grid (x,y) same units as width, Cartesian distances.
flag = 1: grid (x,y) in degrees, width in kilometers, Cartesian distances.
flag = 2: grid (x,y) in degrees, width in km, dx scaled by cos(middle y), Cartesian distances.
The above options are fastest because they allow weight matrix to be computed only once. The
next three options are slower because they recompute weights for each latitude.
flag = 3: grid (x,y) in degrees, width in km, dx scaled by cosine(y), Cartesian distance calculation.
flag = 4: grid (x,y) in degrees, width in km, Spherical distance calculation.
flag = 5: grid (x,y) in Mercator -Jm1 img units, width in km, Spherical distance calculation.
-Fxwidth[/width2][modifiers] Sets the filter type. Choose among convolution and non-convolution filters. Use any filter code x (listed below) followed by the full diameter width. This gives an isotropic
filter; append /width2 for a rectangular filter (requires -Dp or -D0). By default we perform lowpass filtering; append +h to select high-pass filtering. Some filters allow for optional arguments
and modifiers.
Convolution filters (and their codes) are:
(b) Boxcar: All weights are equal.
(c) Cosine Arch: Weights follow a cosine arch curve.
(g) Gaussian: Weights are given by the Gaussian function, where width is 6 times the conventional
Gaussian sigma.
(f) Custom: Weights are given by the precomputed values in the filter weight grid file weight,
which must have odd dimensions; also requires -D0 and output spacing must match input spacing
or be integer multiples.
(o) Operator: Weights are given by the precomputed values in the filter weight grid file weight,
which must have odd dimensions; also requires -D0 and output spacing must match input spacing
or be integer multiples. Weights are assumed to sum to zero so no accumulation of weight sums
and normalization will be done.
Non-convolution filters (and their codes) are:
(m) Median: Returns median value. To select another quantile append +qquantile in the 0-1 range
[Default is 0.5, i.e., median].
(p) Maximum likelihood probability (a mode estimator): Return modal value. If more than one
mode is found we return their average value. Append +l or +u if you rather want to return the
lowermost or uppermost of the modal values.
(h) Histogram mode (another mode estimator): Return the modal value as the center of the dominant peak in a histogram. Append /binwidth to specify the binning interval. Use modifier +c to
center the bins on multiples of binwidth [Default has bin edges that are multiples of binwidth]. If
more than one mode is found we return their average value. Append +l or +u if you rather want to
return the lowermost or uppermost of the modal values.
(l) Lower: Return the minimum of all values.
(L) Lower: Return minimum of all positive values only.
1.37. grdfilter
135
136
1.37.7 Examples
Suppose that north_pacific_etopo5.nc is a file of 5 minute bathymetry from 140E to 260E and 0N to
50N, and you want to find the medians of values within a 300km radius (600km full width) of the output
points, which you choose to be from 150E to 250E and 10N to 40N, and you want the output values
every 0.5 degree. Using spherical distance calculations, you need:
gmt grdfilter north_pacific_etopo5.nc -Gfiltered_pacific.nc -Fm600 \
-D4 -R150/250/10/40 -I0.5 -V
If we instead wanted a high-pass result then one can perform the corresponding low-pass filter using a
coarse grid interval as grdfilter will resample the result to the same resolution as the input grid so we can
compute the residuals, e.g.,
gmt grdfilter north_pacific_etopo5.nc -Gresidual_pacific.nc -Fm600+h \
-D4 -R150/250/10/40 -I0.5 -V
Here, the residual_pacific.nc grid will have the same 5 minute resolution as the original.
To filter the dataset in ripples.nc using a custom anisotropic Gaussian filter exp (-0.5*r^2) whose distances r from the center is given by (2x^2 + y^2 -2xy)/6, with major axis at an angle of 63 degrees with
the horizontal, try
gmt grdmath -R-10/10/-10/10 -I1 X 2 POW 2 MUL Y 2 POW ADD X Y MUL 2 MUL \
SUB 6 DIV NEG 2 DIV EXP DUP SUM DIV = gfilter.nc
gmt grdfilter ripples.nc -Ffgfilter.nc -D0 -Gsmooth.nc -V
1.37.8 Limitations
To use the -D5 option the input Mercator grid must be created by img2mercgrd using the -C option so
the origin of the y-values is the Equator (i.e., x = y = 0 correspond to lon = lat = 0).
1.38 grdgradient
grdgradient - Compute directional derivative or gradient from a grid
1.38.1 Synopsis
grdgradient in_grdfile -Gout_grdfile [ -Aazim[/azim2] ] [ -D[a][c][o][n] ] [ E[s|p]azim/elev[/ambient/diffuse/specular/shine] ] [ -Lflag ] [ -N[e][t][amp][/sigma[/offset]] ] [
-Rregion ] [ -Sslopefile ] [ -V[level] ] [ -fg ] [ -nflags ]
Note: No space is allowed between the option flag and the associated arguments.
1.38. grdgradient
137
1.38.2 Description
grdgradient may be used to compute the directional derivative in a given direction (-A), or the direction
(-S) [and the magnitude (-D)] of the vector gradient of the data.
Estimated values in the first/last row/column of output depend on boundary conditions (see -L).
1.38.6 Hints
If you dont know what -N options to use to make an intensity file for grdimage or grdview, a good first
try is -Ne0.6.
Usually 255 shades are more than enough for visualization purposes. You can save 75% disk space by
appending =nb/a to the output filename out_grdfile.
If you want to make several illuminated maps of subregions of a large data set, and you need the illumination effects to be consistent across all the maps, use the -N option and supply the same value of sigma
and offset to grdgradient for each map. A good guess is offset = 0 and sigma found by grdinfo -L2 or
-L1 applied to an unnormalized gradient grd.
If you simply need the x- or y-derivatives of the grid, use grdmath.
139
1.38.8 Examples
To make a file for illuminating the data in geoid.nc using exp- normalized gradients in the range [-0.6,0.6]
imitating light sources in the north and west directions:
gmt grdgradient geoid.nc -A0/270 -Ggradients.nc=nb/a -Ne0.6 -V
1.38.9 References
Horn, B.K.P., Hill-Shading and the Reflectance Map, Proceedings of the IEEE, Vol. 69, No. 1, January
1981, pp. 14-47. (http://people.csail.mit.edu/bkph/papers/Hill-Shading.pdf)
1.39 grdhisteq
grdhisteq - Perform histogram equalization for a grid
1.39.1 Synopsis
grdhisteq in_grdfile [ -Gout_grdfile ] [ -Cn_cells ] [ -D[file] ] [ -N[norm] ] [ -Q ] -Rregion -V[level]
Note: No space is allowed between the option flag and the associated arguments.
1.39.2 Description
grdhisteq allows the user to find the data values which divide a given grid file into patches of equal area.
One common use of grdhisteq is in a kind of histogram equalization of an image. In this application,
the user might have a grid of flat topography with a mountain in the middle. Ordinary gray shading of
this file (using grdimage/grdview) with a linear mapping from topography to graytone will result in most
of the image being very dark gray, with the mountain being almost white. One could use grdhisteq to
write to stdout or file an ASCII list of those data values which divide the range of the data into n_cells
segments, each of which has an equal area in the image. Using awk or makecpt one can take this output
and build a CPT; using the CPT with grdimage will result in an image with all levels of gray occurring
equally. Alternatively, see grd2cpt.
The second common use of grdhisteq is in writing a grid with statistics based on some kind of cumulative distribution function. In this application, the output has relative highs and lows in the same (x,y)
locations as the input file, but the values are changed to reflect their place in some cumulative distribution. One example would be to find the lowest 10% of the data: Take a grid, run grdhisteq and make a
grid using n_cells = 10, and then contour the result to trace the 1 contour. This will enclose the lowest
10% of the data, regardless of their original values. Another example is in equalizing the output of grdgradient. For shading purposes it is desired that the data have a smooth distribution, such as a Gaussian.
140
If you run grdhisteq on output from grdgradient and make a grid file output with the Gaussian option,
you will have a grid whose values are distributed according to a Gaussian distribution with zero mean
and unit variance. The locations of these values will correspond to the locations of the input; that is, the
most negative output value will be in the (x,y) location of the most negative input value, and so on.
1.39.6 Examples
To find the height intervals that divide the file heights.nc into 16 divisions of equal area:
gmt grdhisteq heights.nc -C16 -D > levels.d
To make the poorly distributed intensities in the file raw_intens.nc suitable for use with grdimage or
grdview, run
gmt grdhisteq raw_intens.nc -Gsmooth_intens.nc -N -V
1.39. grdhisteq
141
1.39.7 Restrictions
If you use grdhisteq to make a Gaussian output for gradient shading in grdimage or grdview, you should
be aware of the following: the output will be in the range [-x, x], where x is based on the number of data
in the input grid (nx * ny) and the cumulative Gaussian distribution function F(x). That is, let N = nx *
ny. Then x will be adjusted so that F(x) = (N - 1 + 0.5)/N. Since about 68% of the values from a standard
normal distribution fall within +/- 1, this will be true of the output grid. But if N is very large, it is
possible for x to be greater than 4. Therefore, with the grdview program clipping gradients to the range
[-1, 1], you will get correct shading of 68% of your data, while 16% of them will be clipped to -1 and
16% of them clipped to +1. If this makes too much of the image too light or too dark, you should take the
output of grdhisteq and rescale it using grdmath and multiplying by something less than 1.0, to shrink
the range of the values, thus bringing more than 68% of the image into the range [-1, 1]. Alternatively,
supply a normalization factor with -N.
1.40 grdimage
grdimage - Project grids or images and plot them on maps
1.40.1 Synopsis
grdimage grd_z | grd_r grd_g grd_b [ -Aout_img[=driver] ] [ -Ccpt ] [ -D[r] ] [ -Ei[|dpi] ] -Jparameters
[ -G[f|b]color ] [ -I[intensfile|intensity] ] [ -Jz|-Zparameters ] [ -K ] [ -M ] [ -N ] [ -O ] [ -P ] [ -Q
] [ -Rwest/east/south/north[/zmin/zmax][r] ] [ -U[stamp] ] [ -V[level] ] [ -Xx_offset ] [ -Yy_offset ] [
-ccopies ] [ -fflags ] [ -nflags ] [ -pflags ] [ -tr ]
Note: No space is allowed between the option flag and the associated arguments.
1.40.2 Description
grdimage reads one 2-D grid file and produces a gray-shaded (or colored) map by plotting rectangles
centered on each grid node and assigning them a gray-shade (or color) based on the z-value. Alternatively, grdimage reads three 2-D grid files with the red, green, and blue components directly (all must
be in the 0-255 range). Optionally, illumination may be added by providing a file with intensities in the
(-1,+1) range. Values outside this range will be clipped. Such intensity files can be created from the grid
using grdgradient and, optionally, modified by grdmath or grdhisteq. Yet as a third alternative available
when GMT is build with GDAL support the grd_z file can be an image referenced or not (than see -Dr).
In this case the images can be illuminated with the file provided via the -I option. Here if image has no
coordinates those of the intensity file will be used.
When using map projections, the grid is first resampled on a new rectangular grid with the same dimensions. Higher resolution images can be obtained by using the -E option. To obtain the resampled value
(and hence shade or color) of each map pixel, its location is inversely projected back onto the input
grid after which a value is interpolated between the surrounding input grid values. By default bi-cubic
interpolation is used. Aliasing is avoided by also forward projecting the input grid nodes. If two or more
142
nodes are projected onto the same pixel, their average will dominate in the calculation of the pixel value.
Interpolation and aliasing is controlled with the -n option.
The -R option can be used to select a map region larger or smaller than that implied by the extent of the
grid.
A (color) PostScript file is output.
1.40. grdimage
143
-I[intensfile|intensity] Gives the name of a grid file with intensities in the (-1,+1) range, or a constant
intensity to apply everywhere; this simply affects the ambient light. If no argument is given then
we derive an intensity grid from the input data grid grd_z via a call to grdgradient using the arguments -A-45 and -Nt1 for that module. If you want other settings then run grdgradient separately
first. [Default is no illumination].
-Jz|Zparameters (more ...) Set z-axis scaling; same syntax as -Jx.
-K (more ...) Do not finalize the PostScript plot.
-M Force conversion to monochrome image using the (television) YIQ transformation. Cannot be used
with -Q.
-N Do not clip the image at the map boundary (only relevant for non-rectangular maps).
-O (more ...) Append to existing PostScript plot.
-P (more ...) Select Portrait plot orientation.
-Q Make grid nodes with z = NaN transparent, using the colormasking feature in PostScript Level 3
(the PS device must support PS Level 3).
-R[unit]xmin/xmax/ymin/ymax[r] (more ...) Specify the region of interest.
For perspective view p, optionally append /zmin/zmax. (more ...) You may ask for a larger w/e/s/n region
to have more room between the image and the axes. A smaller region than specified in the grid file will
result in a subset of the grid [Default is the region given by the grid file].
-U[just/dx/dy/][c|label] (more ...) Draw GMT time stamp logo on plot.
-V[level] (more ...) Select verbosity level [c].
-X[a|c|f|r][x-shift[u]]
-Y[a|c|f|r][y-shift[u]] (more ...) Shift plot origin.
-ccopies (more ...) Specify number of plot copies [Default is 1].
-f[i|o]colinfo (more ...) Specify data types of input and/or output columns.
-n[b|c|l|n][+a][+bBC][+c][+tthreshold] (more ...) Select interpolation mode for grids.
-p[x|y|z]azim/elev[/zlevel][+wlon0/lat0[/z0]][+vx0/y0] (more ...) Select perspective view.
-t[transp] (more ...) Set PDF transparency level in percent.
-^ or just - Print a short message about the syntax of the command, then exits (NOTE: on Windows use
just -).
-+ or just + Print an extensive usage (help) message, including the explanation of any module-specific
option (but not the GMT common options), then exits.
-? or no arguments Print a complete usage (help) message, including the explanation of options, then
exits.
144
1.40.8 Examples
For a quick-and-dirty illuminated color map of the data in the file stuff.nc, with the maximum map
dimension limited to be 6 inches, try
gmt grdimage stuff.nc -JX6i+ -I > quick.ps
To gray-shade the file hawaii_grav.nc with shades given in shades.cpt on a Lambert map at 1.5 cm/degree
along the standard parallels 18 and 24, and using 1 degree tickmarks:
gmt grdimage hawaii_grav.nc -Jl18/24/1.5c -Cshades.cpt -B1 > hawaii_grav_image.ps
To create an illuminated color PostScript plot of the gridded data set image.nc, using the intensities
provided by the file intens.nc, and color levels in the file colors.cpt, with linear scaling at 10 inch/x-unit,
tickmarks every 5 units:
gmt grdimage image.nc -Jx10i -Ccolors.cpt -Iintens.nc -B5 > image.ps
To create an false color PostScript plot from the three grid files red.nc, green.nc, and blue.nc, with linear
scaling at 10 inch/x-unit, tickmarks every 5 units:
gmt grdimage red.nc green.nc blue.nc -Jx10i -B5 > rgbimage.ps
When GDAL support is built in: To create a sinusoidal projection of a remotely located Jessica Rabbit
gmt grdimage -JI15c -Rd -Dr \
http://larryfire.files.wordpress.com/2009/07/untooned_jessicarabbit.jpg \
-P > jess.ps
1.40. grdimage
145
1.41 grdinfo
grdinfo - Extract information from grids
1.41.1 Synopsis
grdinfo grdfiles [ -C ] [ -F ] [ -I[dx[/dy]|r|b] ] [ -L[0|1|2] ] [ -M ] [ -Rregion ] [ -T[dz][+a[alpha]] [+s] ]
[ -V[level] ] [ -fflags ]
Note: No space is allowed between the option flag and the associated arguments.
1.41.2 Description
grdinfo reads a 2-D binary grid file and reports metadata and various statistics for the (x,y,z) data in
the grid file(s). The output information contains the minimum/maximum values for x, y, and z, where
the min/max of z occur, the x- and y-increments, and the number of x and y nodes, and [optionally] the
mean, standard deviation, and/or the median, L1 scale of z, and number of nodes set to NaN. We also
report if the grid is pixel- or gridline-registered and if it is a Cartesian or Geographic data set (based on
metadata in the file).
146
-R[unit]xmin/xmax/ymin/ymax[r] (more ...) Specify the region of interest. Using the -R option will
select a subsection of the input grid(s). If this subsection exceeds the boundaries of the grid, only
the common region will be extracted.
-T[dz][+a[alpha]] [+s] Determine min and max z-value. If dz is provided then we first round these
values off to multiples of dz. To exclude the two tails of the distribution when determining the min
and max you can add +a to set the alpha value (in percent [2]): We then sort the grid, exclude the
data in the 0.5*alpha and 100 - 0.5*alpha tails, and revise the min and max. To force a symmetrical
range about zero, using minus/plus the max absolute value of the two extremes, append +s. We
report the result via the text string -Tzmin/zmax or -Tzmin/zmax/dz (if dz was given) as expected
by makecpt.
-V[level] (more ...) Select verbosity level [c].
-f[i|o]colinfo (more ...) Specify data types of input and/or output columns.
-^ or just - Print a short message about the syntax of the command, then exits (NOTE: on Windows use
just -).
-+ or just + Print an extensive usage (help) message, including the explanation of any module-specific
option (but not the GMT common options), then exits.
-? or no arguments Print a complete usage (help) message, including the explanation of options, then
exits.
1.41.6 Examples
To obtain all the information about the data set in file hawaii_topo.nc:
gmt grdinfo -L1 -L2 -M hawaii_topo.nc
1.42 grdlandmask
grdlandmask - Create a wet-dry mask grid from shoreline data base
1.42.1 Synopsis
grdlandmask -Gmask_grd_file -Ixinc[unit][=|+][/yinc[unit][=|+]] -Rwest/east/south/north[r] [ Amin_area[/min_level/max_level][+ag|i|s |S][+r|l][ppercent] ] [ -Dresolution[+] ] [ -Nmaskvalues[o] ] [
-V[level] ] [ -r ] [ -x[[-]n] ]
1.42. grdlandmask
147
Note: No space is allowed between the option flag and the associated arguments.
1.42.2 Description
grdlandmask reads the selected shoreline database and uses that information to decide which nodes in
the specified grid are over land or over water. The nodes defined by the selected region and lattice spacing
will be set according to one of two criteria: (1) land vs water, or (2) the more detailed (hierarchical) ocean
vs land vs lake vs island vs pond. The resulting mask may be used in subsequent operations involving
grdmath to mask out data from land [or water] areas.
148
river bodies which we normally include as lakes; append +r to just get river-lakes or +l to just
get regular lakes. By default (+ai) we select the ice shelf boundary as the coastline for Antarctica;
append +ag to instead select the ice grounding line as coastline. For expert users who wish to print
their own Antarctica coastline and islands via psxy you can use +as to skip all GSHHG features
below 60S or +aS to instead skip all features north of 60S. Finally, append +ppercent to exclude
polygons whose percentage area of the corresponding full-resolution feature is less than percent.
See GSHHG INFORMATION below for more details.
-Dresolution[+] Selects the resolution of the data set to use ((f)ull, (h)igh, (i)ntermediate, (l)ow, or
(c)rude). The resolution drops off by ~80% between data sets. [Default is l]. Append + to automatically select a lower resolution should the one requested not be available [abort if not found].
Alternatively, choose (a)uto to automatically select the best resolution given the chosen region.
Note that because the coastlines differ in details a node in a mask file using one resolution is not
guaranteed to remain inside [or outside] when a different resolution is selected.
-Nmaskvalues[o] Sets the values that will be assigned to nodes. Values can be any number, including
the textstring NaN. Append o to let nodes exactly on feature boundaries be considered outside
[Default is inside]. Specify this information using 1 of 2 formats:
-Nwet/dry.
-Nocean/land/lake/island/pond.
[Default is 0/1/0/1/0 (i.e., 0/1)].
-V[level] (more ...) Select verbosity level [c].
-r (more ...) Set pixel node registration [gridline].
-x[[-]n] (more ...) Limit number of cores used in multi-threaded algorithms (OpenMP required).
-^ or just - Print a short message about the syntax of the command, then exits (NOTE: on Windows use
just -).
-+ or just + Print an extensive usage (help) message, including the explanation of any module-specific
option (but not the GMT common options), then exits.
-? or no arguments Print a complete usage (help) message, including the explanation of options, then
exits.
1.42. grdlandmask
149
1.42.6 Examples
To set all nodes on land to NaN, and nodes over water to 1, using the high resolution data set, do
gmt grdlandmask -R-60/-40/-40/-30 -Dh -I5m -N1/NaN -Gland_mask.nc -V
To make a 1x1 degree global grid with the hierarchical levels of the nodes based on the low resolution
data:
gmt grdlandmask -R0/360/-90/90 -Dl -I1 -N0/1/2/3/4 -Glevels.nc -V
1.43 grdmask
grdmask - Create mask grid from polygons or point coverage
1.43.1 Synopsis
grdmask pathfiles -Gmask_grd_file -Iincrement -Rregion [ -A[m|p|x|y] ] [ -N[z|Z|p|P]values ] [ Ssearch_radius[unit] ] [ -V[level] ] [ -bibinary ] [ -dinodata ] [ -fflags ] [ -ggaps ] [ -hheaders ] [
-iflags ] [ -r ] [ -x[[-]n] ] [ -:[i|o] ]
Note: No space is allowed between the option flag and the associated arguments.
1.43.2 Description
grdmask can operate in two different modes. 1. It reads one or more pathfiles that each define a closed
polygon. The nodes defined by the specified region and lattice spacing will be set equal to one of three
150
possible values depending on whether the node is outside, on the polygon perimeter, or inside the polygon. The resulting mask may be used in subsequent operations involving grdmath to mask out data
from polygonal areas. 2. The pathfiles simply represent data point locations and the mask is set to the
inside or outside value depending on whether a node is within a maximum distance from the nearest
data point. If the distance specified is zero then only the nodes nearest each data point are considered
inside.
1.43. grdmask
151
-bi[ncols][t] (more ...) Select native binary input. [Default is 2 input columns].
-dinodata (more ...) Replace input columns that equal nodata with NaN.
-f[i|o]colinfo (more ...) Specify data types of input and/or output columns.
-g[a]x|y|d|X|Y|D|[col]z[+|-]gap[u] (more ...) Determine data gaps and line breaks.
-h[i|o][n][+c][+d][+rremark][+rtitle] (more ...) Skip or produce header record(s).
-icols[l][sscale][ooffset][,...] (more ...) Select input columns (0 is first column).
-r (more ...) Set pixel node registration [gridline].
-x[[-]n] (more ...) Limit number of cores used in multi-threaded algorithms (OpenMP required).
-^ or just - Print a short message about the syntax of the command, then exits (NOTE: on Windows use
just -).
-+ or just + Print an extensive usage (help) message, including the explanation of any module-specific
option (but not the GMT common options), then exits.
-? or no arguments Print a complete usage (help) message, including the explanation of options, then
exits.
1.43.5 Units
For map distance unit, append unit d for arc degree, m for arc minute, and s for arc second, or e for
meter [Default], f for foot, k for km, M for statute mile, n for nautical mile, and u for US survey foot.
By default we compute such distances using a spherical approximation with great circles. Prepend - to
a distance (or the unit is no distance is given) to perform Flat Earth calculations (quicker but less
accurate) or prepend + to perform exact geodesic calculations (slower but more accurate).
152
the gmt.conf file or on the command line. In addition, the unit attribute of the time variable will indicate
both this unit and epoch.
1.43.8 Examples
To set all nodes inside and on the polygons coastline_*.xy to 0, and outside points to 1, do
gmt grdmask coastline_*.xy -R-60/-40/-40/-30 -I5m -N1/0/0 -Gland_mask.nc=nb -V
To assign polygon IDs to the gridnodes using the insides of the polygons in plates.gmt, based on the
attribute POL_ID, do
gmt grdmask plates.gmt -R-40/40/-40/40 -I2m -Nz -Gplate_IDs.nc -aZ=POL_ID -V
Same exercise, but instead compute running polygon IDs starting at 100, do
gmt grdmask plates.gmt -R-40/40/-40/40 -I2m -Np100 -Gplate_IDs.nc -V
1.44 grdmath
grdmath - Reverse Polish Notation (RPN) calculator for grids (element by element)
1.44.1 Synopsis
grdmath [ -Amin_area[/min_level/max_level][+ag|i|s |S][+r|l][ppercent] ] [ -Dresolution[+] ] [ Iincrement ] [ -M ] [ -N ] [ -Rregion ] [ -V[level] ] [ -bibinary ] [ -dinodata ] [ -fflags ] [ -hheaders
] [ -iflags ] [ -nflags ] [ -r ] [ -x[[-]n] ] operand [ operand ] OPERATOR [ operand ] OPERATOR ... =
outgrdfile
Note: No space is allowed between the option flag and the associated arguments.
1.44.2 Description
grdmath will perform operations like add, subtract, multiply, and divide on one or more grid files or
constants using Reverse Polish Notation (RPN) syntax (e.g., Hewlett-Packard calculator-style). Arbitrarily complicated expressions may therefore be evaluated; the final result is written to an output grid
file. Grid operations are element-by-element, not matrix manipulations. Some operators only require
one operand (see below). If no grid files are used in the expression then options -R, -I must be set (and
optionally -r). The expression = outgrdfile can occur as many times as the depth of the stack allows in
order to save intermediate results. Complicated or frequently occurring expressions may be coded as a
macro for future use or stored and recalled via named memory locations.
1.44. grdmath
153
-dinodata (more ...) Replace input columns that equal nodata with NaN.
-f[i|o]colinfo (more ...) Specify data types of input and/or output columns.
-g[a]x|y|d|X|Y|D|[col]z[+|-]gap[u] (more ...) Determine data gaps and line breaks.
-h[i|o][n][+c][+d][+rremark][+rtitle] (more ...) Skip or produce header record(s).
-icols[l][sscale][ooffset][,...] (more ...) Select input columns (0 is first column).
-n[b|c|l|n][+a][+bBC][+c][+tthreshold] (more ...) Select interpolation mode for grids.
-r (more ...) Set pixel node registration [gridline]. Only used with -R -I.
-x[[-]n] (more ...) Limit number of cores used in multi-threaded algorithms (OpenMP required).
-^ or just - Print a short message about the syntax of the command, then exits (NOTE: on Windows use
just -).
-+ or just + Print an extensive usage (help) message, including the explanation of any module-specific
option (but not the GMT common options), then exits.
-? or no arguments Print a complete usage (help) message, including the explanation of options, then
exits.
1.44.5 Operators
Choose among the following 200 operators. args are the number of input and output arguments.
Operator
ABS
ACOS
ACOSH
ACOT
ACSC
ADD
AND
ARC
AREA
ASEC
ASIN
ASINH
ATAN
ATAN2
ATANH
BCDF
BPDF
BEI
BER
BITAND
BITLEFT
BITNOT
BITOR
BITRIGHT
1.44. grdmath
args
11
11
11
11
11
21
21
21
01
11
11
11
11
21
11
31
31
11
11
21
21
11
21
21
Returns
abs (A)
acos (A)
acosh (A)
acot (A)
acsc (A)
A+B
B if A == NaN, else A
Return arc(A,B) on [0 pi]
Area of each gridnode cell (in km^2 if geographic)
asec (A)
asin (A)
asinh (A)
atan (A)
atan2 (A, B)
atanh (A)
Binomial cumulative distribution function for p = A, n = B, and x = C
Binomial probability density function for p = A, n = B, and x = C
bei (A)
ber (A)
A & B (bitwise AND operator)
A << B (bitwise left-shift operator)
~A (bitwise NOT operator, i.e., return twos complement)
A | B (bitwise OR operator)
A >> B (bitwise right-shift operator)
Continued on next page
155
BITTEST
BITXOR
CAZ
CBAZ
CDIST
CDIST2
CEIL
CHICRIT
CHICDF
CHIPDF
COMB
CORRCOEFF
COS
COSD
COSH
COT
COTD
CSC
CSCD
CURV
D2DX2
D2DY2
D2DXY
D2R
DDX
DDY
DEG2KM
DENAN
DILOG
DIV
DUP
ECDF
ECRIT
EPDF
ERF
ERFC
EQ
ERFINV
EXCH
EXP
FACT
EXTREMA
FCDF
FCRIT
FLIPLR
FLIPUD
FLOOR
FMOD
156
21
21
21
21
21
21
11
21
21
21
21
21
11
11
11
11
11
11
11
11
11
11
11
11
11
11
11
21
11
21
12
21
21
21
11
11
21
11
22
11
11
11
31
31
11
11
11
21
FPDF
GE
GT
HYPOT
I0
I1
IFELSE
IN
INRANGE
INSIDE
INV
ISFINITE
ISNAN
J0
J1
JN
K0
K1
KEI
KER
KM2DEG
KN
KURT
LCDF
LCRIT
LDIST
LDIST2
LDISTG
LE
LOG
LOG10
LOG1P
LOG2
LMSSCL
LMSSCLW
LOWER
LPDF
LRAND
LT
MAD
MAX
MEAN
MEANW
MEDIAN
MEDIANW
MIN
MOD
MODE
1.44. grdmath
31
21
21
21
11
11
31
21
31
11
11
11
11
11
11
21
11
11
11
11
11
21
11
11
11
11
21
01
21
11
11
11
11
11
21
11
11
21
21
11
21
11
21
11
21
21
21
11
MODEW
MUL
NAN
NEG
NEQ
NORM
NOT
NRAND
OR
PCDF
PDIST
PDIST2
PERM
PLM
PLMg
POINT
POP
POW
PPDF
PQUANT
PQUANTW
PSI
PV
QV
R2
R2D
RAND
RCDF
RCRIT
RINT
RMS
RPDF
ROLL
ROTX
ROTY
SDIST
SDIST2
SAZ
SBAZ
SEC
SECD
SIGN
SIN
SINC
SIND
SINH
SKEW
SQR
158
21
21
21
11
21
11
11
21
21
21
11
21
21
31
31
12
10
21
21
21
31
11
31
31
21
11
21
11
11
11
11
11
20
21
21
21
21
21
21
11
11
11
11
11
11
11
11
11
11
11
21
11
11
11
21
11
11
11
11
21
21
21
21
21
11
11
21
31
31
31
11
21
11
11
22
22
21
11
11
11
sqrt (A)
Standard deviation of A
Weighted standard deviation of A for weights in B
Heaviside step function: H(A)
Heaviside step function in x: H(x-A)
Heaviside step function in y: H(y-A)
A-B
Sum of all values in A
tan (A) (A in radians)
tan (A) (A in degrees)
tanh (A)
Unit weights cosine-tapered to zero within A and B of x and y grid margins
Students t cumulative distribution function for t = A, and nu = B
Students t distribution critical value for alpha = A and nu = B
Chebyshev polynomial Tn(-1<t<+1,n), with t = A, and n = B
Students t probability density function for t = A, and nu = B
The highest (maximum) value of A
Variance of A
Weighted variance of A for weights in B
Weibull cumulative distribution function for x = A, scale = B, and shape = C
Weibull distribution critical value for alpha = A, scale = B, and shape = C
Weibull density distribution P(x,scale,shape), with x = A, scale = B, and shape = C
wrap A in radians onto [-pi,pi]
0 if A == NaN and B == NaN, NaN if B == NaN, else A
Bessel function of A (2nd kind, order 0)
Bessel function of A (2nd kind, order 1)
Re and Im orthonormalized spherical harmonics degree A order B
Cos and Sin normalized spherical harmonics degree A order B (geophysical convention)
Bessel function of A (2nd kind, order B)
Normal cumulative distribution function for z = A
Normal probability density function for z = A
Normal distribution critical value for alpha = A
1.44.6 Symbols
The following symbols have special meaning:
1.44. grdmath
159
PI
E
EULER
EPS_F
XMIN
XMAX
XRANGE
XINC
NX
YMIN
YMAX
YRANGE
YINC
NY
X
Y
XNORM
YNORM
XCOL
YROW
3.1415926...
2.7182818...
0.5772156...
1.192092896e-07 (single precision epsilon
Minimum x value
Maximum x value
Range of x values
x increment
The number of x nodes
Minimum y value
Maximum y value
Range of y values
y increment
The number of y nodes
Grid with x-coordinates
Grid with y-coordinates
Grid with normalized [-1 to +1] x-coordinates
Grid with normalized [-1 to +1] y-coordinates
Grid with column numbers 0, 1, ..., NX-1
Grid with row numbers 0, 1, ..., NY-1
160
return two grids, the real (cosine) and imaginary (sine) component of the complex spherical harmonic. Use the POP operator (and EXCH) to get rid of one of them, or save both by giving two
consecutive = file.nc calls.
The orthonormalized complex harmonics YLM are most commonly used in physics and seismology. The square of YLM integrates to 1 over a sphere. In geophysics, YLMg is normalized to
produce unit power when averaging the cosine and sine terms (separately!) over a sphere (i.e.,
their squares each integrate to 4 pi). The Condon-Shortley phase (-1)^M is not included in YLM
or YLMg, but it can be added by using -M as argument.
6. All the derivatives are based on central finite differences, with natural boundary conditions, and
are Cartesian derivatives.
7. Files that have the same names as some operators, e.g., ADD, SIGN, =, etc. should be identified
by prepending the current directory (i.e., ./LOG).
8. Piping of files is not allowed.
9. The stack depth limit is hard-wired to 100.
10. All functions expecting a positive radius (e.g., LOG, KEI, etc.) are passed the absolute value
of their argument. (9) The bitwise operators (BITAND, BITLEFT, BITNOT, BITOR, BITRIGHT, BITTEST, and BITXOR) convert a grids single precision values to unsigned 32-bit
ints to perform the bitwise operations. Consequently, the largest whole integer value that can be
stored in a float grid is 2^24 or 16,777,216. Any higher result will be masked to fit in the lower
24 bits. Thus, bit operations are effectively limited to 24 bit. All bitwise operators return NaN if
given NaN arguments or bit-settings <= 0.
11. When OpenMP support is compiled in, a few operators will take advantage of the ability to spread
the load onto several cores. At present, the list of such operators is: LDIST.
1.44. grdmath
161
the gmt.conf file or on the command line. In addition, the unit attribute of the time variable will indicate
both this unit and epoch.
1.44.13 Macros
Users may save their favorite operator combinations as macros via the file grdmath.macros in their
current or user directory. The file may contain any number of macros (one per record); comment lines
starting with # are skipped. The format for the macros is name = arg1 arg2 ... arg2 : comment where
name is how the macro will be used. When this operator appears on the command line we simply replace
it with the listed argument list. No macro may call another macro. As an example, the following macro
expects three arguments (radius x0 y0) and sets the modes that are inside the given circle to 1 and those
outside to 0:
INCIRCLE = CDIST EXCH DIV 1 LE : usage: r x y INCIRCLE to return 1 inside circle
Note: Because geographic or time constants may be present in a macro, it is required that the optional
comment flag (:) must be followed by a space.
1.44.14 Examples
To compute all distances to north pole:
gmt grdmath -Rg -I1 0 90 SDIST = dist_to_NP.nc
Given the file ages.nc, which holds seafloor ages in m.y., use the relation depth(in m) = 2500 + 350 *
sqrt (age) to estimate normal seafloor depths:
gmt grdmath ages.nc SQRT 350 MUL 2500 ADD = depths.nc
To find the angle a (in degrees) of the largest principal stress from the stress tensor given by the three
files s_xx.nc s_yy.nc, and s_xy.nc from the relation tan (2*a) = 2 * s_xy / (s_xx - s_yy), use
gmt grdmath 2 s_xy.nc MUL s_xx.nc s_yy.nc SUB DIV ATAN 2 DIV = direction.nc
To calculate the fully normalized spherical harmonic of degree 8 and order 4 on a 1 by 1 degree world
map, using the real amplitude 0.4 and the imaginary amplitude 1.1:
gmt grdmath -R0/360/-90/90 -I1 8 4 YLM 1.1 MUL EXCH 0.4 MUL ADD = harm.nc
To extract the locations of local maxima that exceed 100 mGal in the file faa.nc:
gmt grdmath faa.nc DUP EXTREMA 2 EQ MUL DUP 100 GT MUL 0 NAN = z.nc
gmt grd2xyz z.nc -s > max.xyz
To demonstrate the use of named variables, consider this radial wave where we store and recall the
normalized radial arguments in radians:
gmt grdmath -R0/10/0/10 -I0.25 5 5 CDIST 2 MUL PI MUL 5 DIV STO@r COS @r SIN MUL
= wave.nc
1.44.15 References
Abramowitz, M., and I. A. Stegun, 1964, Handbook of Mathematical Functions, Applied Mathematics
Series, vol. 55, Dover, New York.
Holmes, S. A., and W. E. Featherstone, 2002, A unified approach to the Clenshaw summation and the
recursive computation of very high degree and order normalised associated Legendre functions. Journal
of Geodesy, 76, 279-299.
Press, W. H., S. A. Teukolsky, W. T. Vetterling, and B. P. Flannery, 1992, Numerical Recipes, 2nd edition,
Cambridge Univ., New York.
Spanier, J., and K. B. Oldman, 1987, An Atlas of Functions, Hemisphere Publishing Corp.
1.45 grdpaste
grdpaste - Join two grids along their common edge
1.45. grdpaste
163
1.45.1 Synopsis
grdpaste file_a.nc file_b.nc -Goutfile.nc [ -V[level] ] [ -fflags ]
Note: No space is allowed between the option flag and the associated arguments.
1.45.2 Description
grdpaste will combine file_a.nc and file_b.nc into outfile.nc by pasting them together along their common edge. Files file_a.nc and file_b.nc must have the same dx, dy and have one edge in common. If
in doubt, check with grdinfo and use grdcut and/or grdsample if necessary to prepare the edge joint.
Note: For geographical grids, you may have to use -f to handle periodic longitudes unless the input grids
are properly recognized as such via their meta-data.
1.45.6 Examples
Suppose file_a.nc is 150E - 180E and 0 - 30N, and file_b.nc is 150E - 180E, -30S - 0, then you can make
outfile.nc which will be 150 - 180 and -30S - 30N by:
gmt grdpaste file_a.nc file_b.nc -Goutfile.nc -V -fg
164
1.46 grdproject
grdproject - Forward and inverse map transformation of grids
1.46.1 Synopsis
grdproject in_grdfile -Gout_grdfile -Jparameters [ -C[dx/dy] ] [ -Dxinc[unit][=|+][/yinc[unit][=|+]] ] [
-Edpi ] [ -F[c|i|p|e|f|k|M|n|u] ] [ -I ] [ -Mc|i|p ] [ -Rregion ] [ -V[level] ] [ -nflags ] [ -r ]
Note: No space is allowed between the option flag and the associated arguments.
1.46.2 Description
grdproject will do one of two things depending whether -I has been set. If set, it will transform a gridded data set from a rectangular coordinate system onto a geographical system by resampling the surface
at the new nodes. If not set, it will project a geographical gridded data set onto a rectangular grid. To obtain the value at each new node, its location is inversely projected back onto the input grid after which a
value is interpolated between the surrounding input grid values. By default bi-cubic interpolation is used.
Aliasing is avoided by also forward projecting the input grid nodes. If two or more nodes are projected
onto the same new node, their average will dominate in the calculation of the new node value. Interpolation and aliasing is controlled with the -n option. The new node spacing may be determined in one of
several ways by specifying the grid spacing, number of nodes, or resolution. Nodes not constrained by
input data are set to NaN.
The -R option can be used to select a map region larger or smaller than that implied by the extent of the
grid file.
1.46. grdproject
165
-Edpi Set the resolution for the new grid in dots per inch.
-F[c|i|p|e|f|k|M|n|u] Force 1:1 scaling, i.e., output (or input, see -I) data are in actual projected meters
[e]. To specify other units, append f (foot), k (km), M (statute mile), n (nautical mile), u (US
survey foot), i (inch), c (cm), or p (point). Without -F, the output (or input, see -I) are in the units
specified by PROJ_LENGTH_UNIT (but see -M).
-I Do the Inverse transformation, from rectangular to geographical.
-Mc|i|p Append c, i, or p to indicate that cm, inch, or point should be the projected measure unit [Default
is set by PROJ_LENGTH_UNIT in gmt.conf ]. Cannot be used with -F.
-R[unit]xmin/xmax/ymin/ymax[r] (more ...) Specify the region of interest. You may ask to project only
a subset of the grid by specifying a smaller input w/e/s/n region [Default is the region given by the
grid file].
-V[level] (more ...) Select verbosity level [c].
-n[b|c|l|n][+a][+bBC][+c][+tthreshold] (more ...) Select interpolation mode for grids.
-r (more ...) Set pixel node registration [gridline].
-^ or just - Print a short message about the syntax of the command, then exits (NOTE: on Windows use
just -).
-+ or just + Print an extensive usage (help) message, including the explanation of any module-specific
option (but not the GMT common options), then exits.
-? or no arguments Print a complete usage (help) message, including the explanation of options, then
exits.
1.46.6 Examples
To transform the geographical grid dbdb5.nc onto a pixel Mercator grid at 300 dpi, run
gmt grdproject dbdb5.nc -R20/50/12/25 -Jm0.25i -E300 -r -Gdbdb5_merc.nc
To inversely transform the file topo_tm.nc back onto a geographical grid, use
gmt grdproject topo_tm.nc -R-80/-70/20/40 -Jt-75/1:500000 -I -D5m -V -Gtopo.nc
This assumes, of course, that the coordinates in topo_tm.nc were created with the same projection parameters.
To inversely transform the file topo_utm.nc (which is in UTM meters) back to a geographical grid we
specify a one-to-one mapping with meter as the measure unit:
gmt grdproject topo_utm.nc -R203/205/60/65 -Ju5/1:1 -I -Mm -Gtopo.nc -V
166
To inversely transform the file data.nc (which is in Mercator meters with Greenwich as the central
longitude and a false easting of -4 and produced on the ellipse WGS-72) back to a geographical grid we
specify a one-to-one mapping with meter as the measure unit:
gmt grdproject data.nc -Jm/1:1 -I -F -C-4/0 -Gdata_geo.nc -V --PROJ_ELLIPSOID=WGS72
1.46.7 Restrictions
The boundaries of a projected (rectangular) data set will not necessarily give rectangular geographical
boundaries (Mercator is one exception). In those cases some nodes may be unconstrained (set to NaN).
To get a full grid back, your input grid may have to cover a larger area than you are interested in.
1.47 grdraster
grdraster - Extract subregion from a binary raster and save as a GMT grid
1.47.1 Synopsis
grdraster [ filenumber | text pattern ] -Rregion [ -Ggrdfile ] [ -Iincrement ] [ -Jparameters ] [ -V[level]
] [ -bobinary ] [ -donodata ] [ -oflags ]
Note: No space is allowed between the option flag and the associated arguments.
1.47.2 Description
grdraster reads a file called grdraster.info from the current working directory, the directories pointed to by the environment variables $GMT_USERDIR and $GMT_DATADIR, or in
$GMT_SHAREDIR/dbase (in that order). The file grdraster.info defines binary arrays of data stored
in scan-line format in data files. Each file is given a filenumber in the info file. grdraster figures out
how to load the raster data into a grid file spanning a region defined by -R. By default the grid spacing equals the raster spacing. The -I option may be used to sub-sample the raster data. No filtering or
interpolating is done, however; the x_inc and y_inc of the grid must be multiples of the increments of
the raster file and grdraster simply takes every nth point. The output of grdraster is either grid or
pixel registered depending on the registration of the raster used. It is up to the GMT system person to
maintain the grdraster.info file in accordance with the available rasters at each site. Raster data sets are
not supplied with GMT but can be obtained by anonymous ftp and on CD-ROM (see README page in
dbase directory). grdraster will list the available files if no arguments are given. Finally, grdraster will
write xyz-triplets to stdout if no output gridfile name is given
1.47. grdraster
167
168
1.47.5 Examples
To extract data from raster 1, taking one point every 30 minutes, in an area extended beyond 360 degrees
to allow later filtering, run
gmt grdraster 1 -R-4/364/-62/62 -I30m -Gdata.nc
To obtain data for an oblique Mercator projection we need to extract more data that is actually used.
This is necessary because the output of grdraster has edges defined by parallels and meridians, while
the oblique map in general does not. Hence, to get all the data from the ETOPO2 data needed to make a
contour map for the region defined by its lower left and upper right corners and the desired projection,
use
gmt grdraster ETOPO2 -R160/20/220/30r -Joc190/25.5/292/69/1 -Gdata.nc
To extract data from the 2 min Geoware relief blend and write it as binary double precision xyz-triplets
to standard output:
gmt grdraster "2 min Geoware" -R20/25/-10/5 -bo > triplets.b
1.48 grdsample
grdsample - Resample a grid onto a new lattice
1.48.1 Synopsis
grdsample in_grdfile -Gout_grdfile [ -Iincrement ] [ -Rregion ] [ -T ] [ -V[level] ] [ -fflags ] [ -nflags ]
[ -rreg ] [ -x[[-]n] ]
Note: No space is allowed between the option flag and the associated arguments.
1.48. grdsample
169
1.48.2 Description
grdsample reads a grid file and interpolates it to create a new grid file with either: a different registration
(-r or -T); or, a new grid-spacing or number of nodes (-I), and perhaps also a new sub-region (-R). A
bicubic [Default], bilinear, B-spline or nearest-neighbor interpolation is used; see -n for settings. Note
that using -R only is equivalent to grdcut or grdedit -S. grdsample safely creates a fine mesh from a
coarse one; the converse may suffer aliasing unless the data are filtered using grdfft or grdfilter.
When -R is omitted, the output grid will cover the same region as the input grid. When -I is omitted, the
grid spacing of the output grid will be the same as the input grid. Either -r or -T can be used to change
the grid registration. When omitted, the output grid will have the same registration as the input grid.
170
-? or no arguments Print a complete usage (help) message, including the explanation of options, then
exits.
1.48.8 Hints
If an interpolation point is not on a node of the input grid, then a NaN at any node in the neighborhood
surrounding the point will yield an interpolated NaN. Bicubic interpolation [default] yields continuous
first derivatives but requires a neighborhood of 4 nodes by 4 nodes. Bilinear interpolation [-n] uses only
a 2 by 2 neighborhood, but yields only zero-order continuity. Use bicubic when smoothness is important.
Use bilinear to minimize the propagation of NaNs.
1.48.9 Examples
To resample the 5 x 5 minute grid in hawaii_5by5_topo.nc onto a 1 minute grid:
gmt grdsample hawaii_5by5_topo.nc -I1m -Ghawaii_1by1_topo.nc
To translate the gridline-registered file surface.nc to pixel registration while keeping the same region and
grid interval:
gmt grdsample surface.nc -T -Gpixel.nc
171
1.49 grdtrack
grdtrack - Sample grids at specified (x,y) locations
1.49.1 Synopsis
grdtrack [ xyfile ] -Ggrd1 -Ggrd2 ... [ -Af|p|m|r|R[+l] ] [ -Clength[u]/ds[/spacing][+a][+v] ] [ -Ddfile
] [ -Eline[,line,...][+aaz][+d][+iinc[u]][+llength[u]][+nnp][+oaz][+rradius[u] ] [ -N ] [ -Rregion ] [ Smethod/modifiers ] [ -T[radius[u]][+e|p]] [ -V[level] ] [ -Z ] [ -bbinary ] [ -dnodata ] [ -fflags ] [
-ggaps ] [ -hheaders ] [ -iflags ] [ -nflags ] [ -oflags ] [ -sflags ] [ -:[i|o] ]
Note: No space is allowed between the option flag and the associated arguments.
1.49.2 Description
grdtrack reads one or more grid files (or a Sandwell/Smith IMG files) and a table (from file or standard
input; but see -E for exception) with (x,y) [or (lon,lat)] positions in the first two columns (more columns
may be present). It interpolates the grid(s) at the positions in the table and writes out the table with
the interpolated values added as (one or more) new columns. Alternatively (-C), the input is considered
to be line-segments and we create orthogonal cross-profiles at each data point or with an equidistant
separation and sample the grid(s) along these profiles. A bicubic [Default], bilinear, B-spline or nearestneighbor (see -n) interpolation is used, requiring boundary conditions at the limits of the region (see -n;
Default uses natural conditions (second partial derivative normal to edge is zero) unless the grid is
automatically recognized as periodic.)
172
173
grid is sampled this sequence of 1-3 columns is repeated for each grid.
-T[radius[u]][+e|p] To be used with normal grid sampling, and limited to a single, non-IMG grid. If the
nearest node to the input point is NaN, search outwards until we find the nearest non-NaN node
and report that value instead. Optionally specify a search radius which limits the consideration to
points within this distance from the input point. To report the location of the nearest node and its
distance from the input point, append +e. To instead replace the input point with the coordinates
of the nearest node, append +p.
-V[level] (more ...) Select verbosity level [c].
-Z Only write out the sampled z-values [Default writes all columns].
-: Toggles between (longitude,latitude) and (latitude,longitude) input/output. [Default is (longitude,latitude)].
-bi[ncols][t] (more ...) Select native binary input. [Default is 2 input columns].
-bo[ncols][type] (more ...) Select native binary output. [Default is one more than input].
-d[i|o]nodata (more ...) Replace input columns that equal nodata with NaN and do the reverse on output.
-f[i|o]colinfo (more ...) Specify data types of input and/or output columns.
-g[a]x|y|d|X|Y|D|[col]z[+|-]gap[u] (more ...) Determine data gaps and line breaks.
-h[i|o][n][+c][+d][+rremark][+rtitle] (more ...) Skip or produce header record(s).
-icols[l][sscale][ooffset][,...] (more ...) Select input columns (0 is first column).
-n[b|c|l|n][+a][+bBC][+c][+tthreshold] (more ...) Select interpolation mode for grids.
-ocols[,...] (more ...) Select output columns (0 is first column).
-s[cols][a|r] (more ...) Set handling of NaN records.
-^ or just - Print a short message about the syntax of the command, then exits (NOTE: on Windows use
just -).
-+ or just + Print an extensive usage (help) message, including the explanation of any module-specific
option (but not the GMT common options), then exits.
-? or no arguments Print a complete usage (help) message, including the explanation of options, then
exits.
1.49.5 Units
For map distance unit, append unit d for arc degree, m for arc minute, and s for arc second, or e for
meter [Default], f for foot, k for km, M for statute mile, n for nautical mile, and u for US survey foot.
By default we compute such distances using a spherical approximation with great circles. Prepend - to
a distance (or the unit is no distance is given) to perform Flat Earth calculations (quicker but less
accurate) or prepend + to perform exact geodesic calculations (slower but more accurate).
174
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.
1.49.9 Hints
If an interpolation point is not on a node of the input grid, then a NaN at any node in the neighborhood
surrounding the point will yield an interpolated NaN. Bicubic interpolation [default] yields continuous
first derivatives but requires a neighborhood of 4 nodes by 4 nodes. Bilinear interpolation [-n] uses
only a 2 by 2 neighborhood, but yields only zeroth-order continuity. Use bicubic when smoothness is
important. Use bilinear to minimize the propagation of NaNs, or lower threshold.
1.49.10 Examples
To sample the file hawaii_topo.nc along the SEASAT track track_4.xyg (An ASCII table containing
longitude, latitude, and SEASAT-derived gravity, preceded by one header record):
grdtrack track_4.xyg -Ghawaii_topo.nc -h > track_4.xygt
To sample the Sandwell/Smith IMG format file topo.8.2.img (2 minute predicted bathymetry on a
Mercator grid) and the Muller et al age grid age.3.2.nc along the lon,lat coordinates given in the file
cruise_track.xy, try
grdtrack cruise_track.xy -Gtopo.8.2.img,1,1 -Gage.3.2.nc > depths-age.d
To sample the Sandwell/Smith IMG format file grav.18.1.img (1 minute free-air anomalies on a Mercator
grid) along 100-km-long cross-profiles that are orthogonal to the line segment given in the file track.xy,
erecting cross-profiles every 25 km and sampling the grid every 3 km, try
grdtrack track.xy -Ggrav.18.1.img,0.1,1 -C100k/3/25 -Ar > xprofiles.txt
To sample the grid data.nc along a line from the lower left to the upper right corner, using a grid spacing
of 1 km, and output distances as well, try
1.49. grdtrack
175
1.50 grdtrend
grdtrend - Fit trend surface to grids and compute residuals
1.50.1 Synopsis
grdtrend grdfile -Nn_model[r] [ -Ddiff.nc ] [ -Rregion ] [ -Ttrend.nc ] [ -Wweight.nc ]
Note: No space is allowed between the option flag and the associated arguments.
1.50.2 Description
grdtrend reads a 2-D grid file and fits a low-order polynomial trend to these data by [optionally
weighted] least-squares. The trend surface is defined by:
m1 + m2*x + m3*y + m4*x*y + m5*x*x + m6*y*y + m7*x*x*x + m8*x*x*y + m9*x*y*y
+ m10*y*y*y.
The user must specify -Nn_model, the number of model parameters to use; thus, -N3 fits a bilinear
trend, -N6 a quadratic surface, and so on. Optionally, append r to the -N option to perform a robust fit.
In this case, the program will iteratively reweight the data based on a robust scale estimate, in order to
converge to a solution insensitive to outliers. This may be handy when separating a regional field from
a residual which should have non-zero mean, such as a local mountain on a regional surface.
If data file has values set to NaN, these will be ignored during fitting; if output files are written, these
will also have NaN in the same locations.
-Wweight.nc If weight.nc exists, it will be read and used to solve a weighted least-squares problem.
[Default: Ordinary least-squares fit.] If the robust option has been selected, the weights used in
the robust fit will be written to weight.nc.
-^ or just - Print a short message about the syntax of the command, then exits (NOTE: on Windows use
just -).
-+ or just + Print an extensive usage (help) message, including the explanation of any module-specific
option (but not the GMT common options), then exits.
-? or no arguments Print a complete usage (help) message, including the explanation of options, then
exits.
1.50.5 Remarks
The domain of x and y will be shifted and scaled to [-1, 1] and the basis functions are built from
Legendre polynomials. These have a numerical advantage in the form of the matrix which must be
inverted and allow more accurate solutions. NOTE: The model parameters listed with -V are Legendre
polynomial coefficients; they are not numerically equivalent to the m#s in the equation described above.
The description above is to allow the user to match -N with the order of the polynomial surface. See
grdmath if you need to evaluate the trend using the reported coefficients.
1.50.7 Examples
To remove a planar trend from hawaii_topo.nc and write result in hawaii_residual.nc:
gmt grdtrend hawaii_topo.nc -N3 -Dhawaii_residual.nc
To do a robust fit of a bicubic surface to hawaii_topo.nc, writing the result in hawaii_trend.nc and the
weights used in hawaii_weight.nc, and reporting the progress:
gmt grdtrend hawaii_topo.nc -N10r -Thawaii_trend.nc -Whawaii_weight.nc -V
1.51 grdvector
grdvector - Plot vector field from two component grids
1.51. grdvector
177
1.51.1 Synopsis
grdvector compx.nc compy.nc -Jparameters [ -A ] [ -B[p|s]parameters ] [ -Ccpt ] [ -Gfill ] [ -I[x]dx[/dy]
] [ -K ] [ -N ] [ -O ] [ -P ] [ -Qparameters ] [ -Rregion ] [ -S[i|l]scale ] [ -T ] [ -U[stamp] ] [ -Wpen ] [
-Xx_offset ] [ -Yy_offset ] [ -Z ] [ -ccopies ] [ -fflags ] [ -pflags ] [ -ttransp ]
Note: No space is allowed between the option flag and the associated arguments.
1.51.2 Description
grdvector reads two 2-D grid files which represents the x- and y-components of a vector field and
produces a vector field plot by drawing vectors with orientation and length according to the information
in the files. Alternatively, polar coordinate r, theta grids may be given instead.
178
-S[i|l]scale Sets scale for Cartesian vector length in data units per distance measurement unit [1]. Append c, i, or p to indicate the measurement unit (cm, inch,or point). Prepend l to indicate a fixed
length for all vectors. For Geographic data, give scale in data units per km. Use -Si if it is simpler
to give the reciprocal scale in measurement unit per data unit or km per data unit.
-T Means the azimuths of Cartesian data sets should be adjusted according to the signs of the scales in
the x- and y-directions [Leave alone]. This option can be used to convert vector azimuths in cases
when a negative scale is used in one of both directions (e.g., positive down).
-U[just/dx/dy/][c|label] (more ...) Draw GMT time stamp logo on plot.
-V[level] (more ...) Select verbosity level [c].
-Wpen Set pen attributes used for vector outlines [Default: width = default, color = black, style = solid].
-X[a|c|f|r][x-shift[u]]
-Y[a|c|f|r][y-shift[u]] (more ...) Shift plot origin.
-Z The theta grid provided contains azimuths rather than directions (requires -A).
-ccopies (more ...) Specify number of plot copies [Default is 1].
-f[i|o]colinfo (more ...) Specify data types of input and/or output columns.
-p[x|y|z]azim/elev[/zlevel][+wlon0/lat0[/z0]][+vx0/y0] (more ...) Select perspective view.
-t[transp] (more ...) Set PDF transparency level in percent.
-^ or just - Print a short message about the syntax of the command, then exits (NOTE: on Windows use
just -).
-+ or just + Print an extensive usage (help) message, including the explanation of any module-specific
option (but not the GMT common options), then exits.
-? or no arguments Print a complete usage (help) message, including the explanation of options, then
exits.
1.51. grdvector
179
+e places a vector head at the end of the vector path [none]. Optionally, append t for a
terminal line, c for a circle, a for arrow [Default], i for tail, A for plain arrow, and I for plain
tail. Further append l|r to only draw the left or right side of this head [both sides].
+g-|fill turns off vector head fill (if -) or sets the vector head fill [Default fill is used, which
may be no fill].
+l draws half-arrows, using only the left side of specified heads [both sides].
+m places a vector head at the mid-point the vector path [none]. Append f or r for forward
or reverse direction of the vector [forward]. Optionally, append t for a terminal line, c for a
circle, or a for arrow head [Default]. Further append l|r to only draw the left or right side of
this head [both sides]. Cannot be combined with +b or +e.
+nnorm scales down vector attributes (pen thickness, head size) with decreasing length,
where vectors shorter than norm will have their attributes scaled by length/norm [arrow
attributes remains invariant to length].
+oplon/plat specifies the oblique pole for the great or small circles. Only needed for great
circles if +q is given.
+p[-][pen] sets the vector pen attributes. If pen has a leading - then the head outline is not
drawn. [Default pen is used, and head outline is drawn]
+q means the input angle, length data instead represent the start and stop opening angles of
the arc segment relative to the given point.
+r draws half-arrows, using only the right side of specified heads [both sides].
t[b|e]trim will shift the beginning or end point (or both) along the vector segment by the
given trim; append suitable unit. If the modifiers b|e are not used then trim may be two
values separated by a slash, which is used to specify different trims for the two ends. Positive
trims will shorted the vector while negative trims will lengthen it [no trim].
In addition, all but circular vectors may take these modifiers:
+jjust determines how the input x,y point relates to the vector. Choose from beginning
[default], end, or center.
+s means the input angle, length are instead the x, y coordinates of the vector end point.
Finally, Cartesian vectors may take these modifiers:
+zscale[unit] expects input dx,dy vector components and uses the scale to convert to polar
coordinates with length in given unit.
1.51.7 Examples
To draw the vector field given by the files r.nc and theta.nc on a linear plot with scale 5 cm per data
unit, using vector rather than stick plot, scale vector magnitudes so that 10 units equal 1 inch, and center
vectors on the node locations, run
gmt grdvector r.nc theta.nc -Jx5c -A -Q0.1i+e+jc -S10i > gradient.ps
To plot a geographic data sets given the files com_x.nc and comp_y.nc, using a scale of 200 km per data
unit and only plot every 3rd node in either direction, try
180
gmt grdvector comp_x.nc comp_y.nc -Ix3 -JH0/20c -Q0.1i+e+jc -S200 > globe.ps
1.52 grdview
grdview - Create 3-D perspective image or surface mesh from a grid
1.52.1 Synopsis
grdview relief_file -Jparameters [ -B[p|s]parameters ] [ -C[cpt]] [ -Gdrapefile | -Ggrd_r -Ggrd_g Ggrd_b ] [ -Iintensfile|intensity ] [ -Jz|Zparameters ] [ -K ] [ -Nlevel[+gfill] ] [ -O ] [ -P ] [ -Qargs[+m]
] [ -Rwest/east/south/north[/zmin/zmax][r] ] [ -Ssmooth ] [ -T[s][o[pen]] ] [ -U[stamp] ] [ -Wtypepen ]
[ -Xx_offset ] [ -Yy_offset ] [ -ccopies ] [ -nflags ] [ -pflags ] [ -ttransp ]
Note: No space is allowed between the option flag and the associated arguments.
1.52.2 Description
grdview reads a 2-D grid file and produces a 3-D perspective plot by drawing a mesh, painting a colored/grayshaded surface made up of polygons, or by scanline conversion of these polygons to a raster
image. Options include draping a data set on top of a surface, plotting of contours on top of the surface,
and apply artificial illumination based on intensities provided in a separate grid file.
1.52. grdview
181
-Gdrapefile | -Ggrd_r -Ggrd_g -Ggrd_b Drape the image in drapefile on top of the relief provided
by relief_file. [Default is relief_file]. Note that -Jz and -N always refers to the relief_file. The
drapefile only provides the information pertaining to colors, which is looked-up via the CPT (see
-C). Alternatively, give three grid files via separate -G options in the specified order. These files
must contain the red, green, and blue colors directly (in 0-255 range) and no CPT is needed. The
drapefile may be of higher resolution than the relief_file.
-Iintensfile|intensity Gives the name of a grid file with intensities in the (-1,+1) range, or a constant
intensity to apply everywhere. [Default is no illumination].
-K (more ...) Do not finalize the PostScript plot.
-Nlevel[+gfill] Draws a plane at this z-level. If the optional color is provided via the +g modifier, the
frontal facade between the plane and the data perimeter is colored. See -Wf for setting the pen
used for the outline.
-O (more ...) Append to existing PostScript plot.
-P (more ...) Select Portrait plot orientation.
-Qargs[+m] Select one of following settings. For any of these choices, you may force a monochrome
image by appending the modifier +m. Colors are then converted to shades of gray using the
(monochrome television) YIQ transformation
1. Specify m for mesh plot [Default], and optionally append color for a different mesh paint
[white].
2. Specify mx or my for waterfall plots (row or column profiles). Specify color as for plain m
3. Specify s for surface plot, and optionally append m to have mesh lines drawn on top of
surface.
4. Specify i for image plot, and optionally append the effective dpi resolution for the rasterization [100].
5. Specify c. Same as -Qi but will make nodes with z = NaN transparent, using the colormasking feature in PostScript Level 3 (the PS device must support PS Level 3). .
-R[unit]xmin/xmax/ymin/ymax[r] (more ...) Specify the region of interest.
For perspective view p, optionally append /zmin/zmax. (more ...) This option may be used to indicate
the range used for the 3-D axes [Default is region given by the relief_file]. You may ask for a larger
w/e/s/n region to have more room between the image and the axes. A smaller region than specified in
the relief_file will result in a subset of the grid.
-Ssmooth Smooth the contours before plotting (see grdcontour) [Default is no smoothing].
-T[s][o[pen]] Plot image without any interpolation. This involves converting each node-centered bin
into a polygon which is then painted separately. Append s to skip nodes with z = NaN. This option is useful for categorical data where interpolating between values is meaningless. Optionally,
append o to draw the tile outlines, and specify a custom pen if the default pen is not to your liking.
As this option produces a flat surface it cannot be combined with -JZ or -Jz.
-U[just/dx/dy/][c|label] (more ...) Draw GMT time stamp logo on plot.
-V[level] (more ...) Select verbosity level [c].
-Wtypepen
-Wc Draw contour lines on top of surface or mesh (not image). Append pen attributes used
for the contours. [Default: width = 0.75p, color = black, style = solid].
182
-Wm Sets the pen attributes used for the mesh. [Default: width = 0.25p, color = black, style
= solid]. You must also select -Qm or -Qsm for meshlines to be drawn.
-Wf Sets the pen attributes used for the facade. [Default: width = 0.25p, color = black, style
= solid]. You must also select -N for the facade outline to be drawn.
-X[a|c|f|r][x-shift[u]]
-Y[a|c|f|r][y-shift[u]] (more ...) Shift plot origin.
-ccopies (more ...) Specify number of plot copies [Default is 1].
-n[b|c|l|n][+a][+bBC][+c][+tthreshold] (more ...) Select interpolation mode for grids.
-p[x|y|z]azim/elev[/zlevel][+wlon0/lat0[/z0]][+vx0/y0] (more ...) Select perspective view.
-t[transp] (more ...) Set PDF transparency level in percent.
-^ or just - Print a short message about the syntax of the command, then exits (NOTE: on Windows use
just -).
-+ or just + Print an extensive usage (help) message, including the explanation of any module-specific
option (but not the GMT common options), then exits.
-? or no arguments Print a complete usage (help) message, including the explanation of options, then
exits.
1.52.7 Examples
To make a mesh plot from the file hawaii_grav.nc and drawing the contours given in the CPT hawaii.cpt
on a Lambert map at 1.5 cm/degree along the standard parallels 18 and 24, with vertical scale 20
mgal/cm, and looking at the surface from SW at 30 degree elevation, run
gmt grdview hawaii_grav.nc -Jl18/24/1.5c -Chawaii.cpt \
-Jz0.05c -Qm -N-100 -p225/30 -Wc > hawaii_grav_image.ps
1.52. grdview
183
To create a illuminated color perspective plot of the gridded data set image.nc, using the CPT color.rgb,
with linear scaling at 10 cm/x-unit and tickmarks every 5 units, with intensities provided by the file
intens.nc, and looking from the SE, use
gmt grdview image.nc -Jx10.0c -Ccolor.rgb -Qs -p135/30 -Iintens.nc > image3D.ps
To make the same plot using the rastering option with dpi = 50, use
gmt grdview image.nc -Jx10.0c -Ccolor.rgb -Qi50 -p135/30 -Iintens.nc > image3D.ps
To create a color PostScript perspective plot of the gridded data set magnetics.nc, using the CPT
mag_intens.cpt, draped over the relief given by the file topography.nc, with Mercator map width of
6 inch and tickmarks every 1 degree, with intensities provided by the file topo_intens.nc, and looking
from the SE, run
gmt grdview topography.nc -JM6i -Gmagnetics.nc -Cmag_intens.cpt \
-Qs -p140/30 -Itopo_intens.nc > draped3D.ps
Given topo.nc and the Landsat image veggies.ras, first run grd2rgb to get the red, green, and blue grids,
and then drape this image over the topography and shade the result for good measure. The commands
are
gmt grd2rgb veggies.ras -Glayer_%c.nc
gmt grdview topo.nc -JM6i -Qi -p140/30 -Itopo_intens.nc \
-Glayer_r.nc -Glayer_g.nc -Glayer_b.nc > image.ps
1.52.8 Remarks
For the -Qs option: PostScript provides no way of smoothly varying colors within a polygon, so colors can only vary from polygon to polygon. To obtain smooth images this way you may resample the
grid file(s) using grdsample or use a finer grid size when running gridding programs like surface or
nearneighbor. Unfortunately, this produces huge PostScript files. The alternative is to use the -Qi option, which computes bilinear or bicubic continuous color variations within polygons by using scanline
conversion to image the polygons.
1.53 grdvolume
grdvolume - Calculate grid volume and area constrained by a contour
1.53.1 Synopsis
grdvolume grdfile [ -Ccval or -Clow/high/delta or -Crlow/high or -Crcval] [ -Lbase ] [ -Rregion ] [
-S[unit] ] [ -T[c|h] ] [ -V[level] ] [ -Zfact[/shift] ] [ -fflags ] [ -oflags ]
Note: No space is allowed between the option flag and the associated arguments.
184
1.53.2 Description
grdvolume reads a 2-D grid file and calculates the volume contained between the surface and the plane
specified by the given contour (or zero if not given) and reports the area, volume, and maximum mean
height (volume/area). Alternatively, specify a range of contours to be tried and grdvolume will determine the volume and area inside the contour for all contour values. Using -T, the contour that produced
the maximum mean height (or maximum curvature of heights vs contour value) is reported as well. This
feature may be used with grdfilter in designing an Optimal Robust Separator [Wessel, 1998].
185
facilitates so called packing of grids, writing out floating point data as 1- or 2-byte integers. (more ...)
1.53.6 Examples
To determine the volume in km^3 under the surface hawaii_topo.nc (height in km), use
gmt grdvolume hawaii_topo.nc -Sk
To find the volume between the surface peaks.nc and the contour z = 250, use
gmt grdvolume peaks.nc -Sk -C250
To search for the contour, between 100 and 300 in steps of 10, that maximizes the ratio of volume to
surface area for the file peaks.nc, use
gmt grdvolume peaks.nc -Sk -C100/300/10 -Th > results.d
To see the areas and volumes for all the contours in the previous example, use
gmt grdvolume peaks.nc -Sk -C100/300/10 > results.d
To find the volume of water in a lake with its free surface at 0 and max depth of 300 meters, use
gmt grdvolume lake.nc -Cr-300/0
1.53.7 Notes
grdvolume distinguishes between gridline and pixel-registered grids. In both cases the area and volume
are computed up to the grid boundaries. That means that in the first case the grid cells on the boundary
only contribute half their area (and volume), whereas in the second case all grid cells are fully used. The
exception is when the -C flag is used: since contours do not extend beyond the outermost grid point,
both grid types are treated the same. That means the outer rim in pixel oriented grids is ignored when
using the -C flag.
1.53.9 References
Wessel, P., 1998, An empirical method for optimal robust regional-residual separation of geophysical
data, Math. Geol., 30(4), 391-408.
1.54 greenspline
greenspline - Interpolate using Greens functions for splines in 1-3 dimensions
186
1.54.1 Synopsis
greenspline [ table ] [ -Agradfile+f1|2|3|4|5 ] [ -C[n|r|v]value[+ffile] ] [ -Dmode ] [ E[misfitfile] ] [ -Ggrdfile ] [ -Ixinc[/yinc[/zinc]] ] [ -L ] [ -Nnodefile ] [ -Qaz|x/y/z ] [ Rwest/east/south/north[/zmin/zmax][r] ] [ -Sc|t|l|r|p|q[pars] ] [ -Tmaskgrid ] [ -V[level] ] [ -W[w]] [
-bbinary ] [ -dnodata ] [ -fflags ] [ -hheaders ] [ -oflags ] [ -x[[-]n] ] [ -:[i|o] ]
Note: No space is allowed between the option flag and the associated arguments.
1.54.2 Description
greenspline uses the Greens function G(x; x) for the chosen spline and geometry to interpolate data
at regular [or arbitrary] output locations. Mathematically, the solution is composed as w(x) = sum {c(i)
G(x; x(i))}, for i = 1, n, the number of data points {x(i), w(i)}. Once the n coefficients c(i) have been
found the sum can be evaluated at any output point x. Choose between minimum curvature, regularized,
or continuous curvature splines in tension for either 1-D, 2-D, or 3-D Cartesian coordinates or spherical
surface coordinates. After first removing a linear or planar trend (Cartesian geometries) or mean value
(spherical surface) and normalizing these residuals, the least-squares matrix solution for the spline coefficients c(i) is found by solving the n by n linear system w(j) = sum-over-i {c(i) G(x(j); x(i))}, for j = 1, n;
this solution yields an exact interpolation of the supplied data points. Alternatively, you may choose to
perform a singular value decomposition (SVD) and eliminate the contribution from the smallest eigenvalues; this approach yields an approximate solution. Trends and scales are restored when evaluating the
output.
187
eigenvalues needed to explain approximately value % of the data variance. Specify -Cr to use the
largest eigenvalues needed to leave approximately value as the model misfit. If value is not given
then -W is required and we compute value as the rms of the data uncertainties. Alternatively, use
-Cn to select the value largest eigenvalues. If a file is given with -Cv then we save the eigenvalues
instead of the ratios.
-Dmode Sets the distance flag that determines how we calculate distances between data points. Select
mode 0 for Cartesian 1-D spline interpolation: -D0 means (x) in user units, Cartesian distances,
Select mode 1-3 for Cartesian 2-D surface spline interpolation: -D1 means (x,y) in user units,
Cartesian distances, -D2 for (x,y) in degrees, Flat Earth distances, and -D3 for (x,y) in degrees,
Spherical distances in km. Then, if PROJ_ELLIPSOID is spherical, we compute great circle arcs,
otherwise geodesics. Option mode = 4 applies to spherical surface spline interpolation only: -D4
for (x,y) in degrees, use cosine of great circle (or geodesic) arcs. Select mode 5 for Cartesian 3-D
surface spline interpolation: -D5 means (x,y,z) in user units, Cartesian distances.
E[misfitfile]
Evaluate the spline exactly at the input data locations and report statistics of the misfit
(mean, standard deviation, and rms). Optionally, append a filename and we will write the
data table, augmented by two extra columns holding the spline estimate and the misfit.
-Ggrdfile Name of resulting output file. (1) If options -R, -I, and possibly -r are set we produce an
equidistant output table. This will be written to stdout unless -G is specified. Note: for 2-D grids
the -G option is required. (2) If option -T is selected then -G is required and the output file is a
2-D binary grid file. Applies to 2-D interpolation only. (3) If -N is selected then the output is an
ASCII (or binary; see -bo) table; if -G is not given then this table is written to standard output.
Ignored if -C or -C0 is given.
-Ixinc[/yinc[/zinc]] Specify equidistant sampling intervals, on for each dimension, separated by slashes.
-L Do not remove a linear (1-D) or planer (2-D) trend when -D selects mode 0-3 [For those Cartesian
cases a least-squares line or plane is modeled and removed, then restored after fitting a spline
to the residuals]. However, in mixed cases with both data values and gradients, or for spherical
surface data, only the mean data value is removed (and later and restored).
-Nnodefile ASCII file with coordinates of desired output locations x in the first column(s). The resulting
w values are appended to each record and written to the file given in -G [or stdout if not specified];
see -bo for binary output instead. This option eliminates the need to specify options -R, -I, and -r.
-Qaz|x/y/z Rather than evaluate the surface, take the directional derivative in the az azimuth and return
the magnitude of this derivative instead. For 3-D interpolation, specify the three components of
the desired vector direction (the vector will be normalized before use).
-Rxmin/xmax[/ymin/ymax[/zminzmax]] Specify the domain for an equidistant lattice where output predictions are required. Requires -I and optionally -r.
1-D: Give xmin/xmax, the minimum and maximum x coordinates.
2-D: Give xmin/xmax/ymin/ymax, the minimum and maximum x and y coordinates. These may be
Cartesian or geographical. If geographical, then west, east, south, and north specify the Region of
interest, and you may specify them in decimal degrees or in [+-]dd:mm[:ss.xxx][W|E|S|N] format.
The two shorthands -Rg and -Rd stand for global domain (0/360 and -180/+180 in longitude
respectively, with -90/+90 in latitude).
3-D: Give xmin/xmax/ymin/ymax/zmin/zmax, the minimum and maximum x, y and z coordinates.
See the 2-D section if your horizontal coordinates are geographical; note the shorthands -Rg and
-Rd cannot be used if a 3-D domain is specified.
188
-Sc|t|l|r|p|q[pars] Select one of six different splines. The first two are used for 1-D, 2-D, or 3-D Cartesian splines (see -D for discussion). Note that all tension values are expected to be normalized
tension in the range 0 < t < 1: (c) Minimum curvature spline [Sandwell, 1987], (t) Continuous
curvature spline in tension [Wessel and Bercovici, 1998]; append tension[/scale] with tension in
the 0-1 range and optionally supply a length scale [Default is the average grid spacing]. The next
is a 1-D or 2-D spline: (l) Linear (1-D) or Bilinear (2-D) spline; these produce output that do not
exceed the range of the given data. The next is a 2-D or 3-D spline: (r) Regularized spline in
tension [Mitasova and Mitas, 1993]; again, append tension and optional scale. The last two are
spherical surface splines and both imply -D4: (p) Minimum curvature spline [Parker, 1994], (q)
Continuous curvature spline in tension [Wessel and Becker, 2008]; append tension. The G(x; x)
for the last method is slower to compute (a series solution) so we pre-calculate values and use
cubic spline interpolation lookup instead. Optionally append +nN (an odd integer) to change how
many points to use in the spline setup [10001]. The finite Legendre sum has a truncation error
[1e-6]; you can lower that by appending +elimit at the expense of longer run-time.
-Tmaskgrid For 2-D interpolation only. Only evaluate the solution at the nodes in the maskgrid that are
not equal to NaN. This option eliminates the need to specify options -R, -I, and -r.
-V[level] (more ...) Select verbosity level [c].
-W[w] Data one-sigma uncertainties are provided in the last column. We then compute weights that are
inversely proportional to the uncertainties. Append w if weights are given instead of uncertainties.
This results in a weighted least squares fit. Note that this only has an effect if -C is used. [Default
uses no weights or uncertainties].
-bi[ncols][t] (more ...) Select native binary input. [Default is 2-4 input columns (x,w); the number depends on the chosen dimension].
-bo[ncols][type] (more ...) Select native binary output.
-d[i|o]nodata (more ...) Replace input columns that equal nodata with NaN and do the reverse on output.
-f[i|o]colinfo (more ...) Specify data types of input and/or output columns.
-h[i|o][n][+c][+d][+rremark][+rtitle] (more ...) Skip or produce header record(s).
-icols[l][sscale][ooffset][,...] (more ...) Select input columns (0 is first column).
-ocols[,...] (more ...) Select output columns (0 is first column).
-r (more ...) Set pixel node registration [gridline].
-x[[-]n] (more ...) Limit number of cores used in multi-threaded algorithms (OpenMP required).
-^ or just - Print a short message about the syntax of the command, then exits (NOTE: on Windows use
just -).
-+ or just + Print an extensive usage (help) message, including the explanation of any module-specific
option (but not the GMT common options), then exits.
-? or no arguments Print a complete usage (help) message, including the explanation of options, then
exits.
189
To use Cartesian splines in tension but only evaluate the solution where the input mask grid is not NaN,
try
gmt greenspline table_5.11 -Tmask.nc -St0.5 -V -D1 -GWB1998.nc
To use Cartesian generalized splines in tension and return the magnitude of the surface slope in the NW
direction, try
gmt greenspline table_5.11 -R0/6.5/-0.2/6.5 -I0.1 -Sr0.95 -V -D1 -Q-45 -Gslopes.nc
Finally, to use Cartesian minimum curvature splines in recovering a surface where the input data is a
single surface value (pt.txt) and the remaining constraints specify only the surface slope and direction
(slopes.txt), use
gmt greenspline pt.txt -R-3.2/3.2/-3.2/3.2 -I0.1 -Sc -V -D1 -Aslopes.txt+f1 Gslopes.nc
190
1.54.9 Considerations
1. For the Cartesian cases we use the free-space Green functions, hence no boundary conditions
are applied at the edges of the specified domain. For most applications this is fine as the region
typically is arbitrarily set to reflect the extent of your data. However, if your application requires
particular boundary conditions then you may consider using surface instead.
2. In all cases, the solution is obtained by inverting a n x n double precision matrix for the Green function coefficients, where n is the number of data constraints. Hence, your computers memory may
place restrictions on how large data sets you can process with greenspline <greenspline.html>.
Pre-processing your data with blockmean <blockmean.html>, blockmedian <blockmedian.html>,
or blockmode <blockmode.html> is recommended to avoid aliasing and may also control the size
of n. For information, if n = 1024 then only 8 Mb memory is needed, but for n = 10240 we
need 800 Mb. Note that greenspline <greenspline.html> is fully 64-bit compliant if compiled as
such. For spherical data you may consider decimating using gmtspatial <gmtspatial.html> nearest
neighbor reduction.
3. The inversion for coefficients can become numerically unstable when data neighbors are very
close compared to the overall span of the data. You can remedy this by pre-processing the data,
e.g., by averaging closely spaced neighbors. Alternatively, you can improve stability by using the
SVD solution and discard information associated with the smallest eigenvalues (see -C).
4. The series solution implemented for -Sq was developed by Robert L. Parker, Scripps Institution
of Oceanography, which we gratefully acknowledge.
5. If you need to fit a certain 1-D spline through your data points you may wish to consider sample1d
<sample1d.html> instead. It will offer traditional splines with standard boundary conditions (such
as the natural cubic spline, which sets the curvatures at the ends to zero). In contrast, greensplines
1-D spline, as is explained in note 1, does not specify boundary conditions at the end of the data
domain.
1.54.10 Tension
Tension is generally used to suppress spurious oscillations caused by the minimum curvature requirement, in particular when rapid gradient changes are present in the data. The proper amount of tension
can only be determined by experimentation. Generally, very smooth data (such as potential fields) do not
require much, if any tension, while rougher data (such as topography) will typically interpolate better
with moderate tension. Make sure you try a range of values before choosing your final result. Note: the
regularized spline in tension is only stable for a finite range of scale values; you must experiment to find
the valid range and a useful setting. For more information on tension see the references below.
1.54.11 References
Davis, J. C., 1986, Statistics and Data Analysis in Geology, 2nd Edition, 646 pp., Wiley, New York,
Mitasova, H., and L. Mitas, 1993, Interpolation by regularized spline with tension: I. Theory and implementation, Math. Geol., 25, 641-655.
Parker, R. L., 1994, Geophysical Inverse Theory, 386 pp., Princeton Univ. Press, Princeton, N.J.
Sandwell, D. T., 1987, Biharmonic spline interpolation of Geos-3 and Seasat altimeter data, Geophys.
Res. Lett., 14, 139-142.
1.54. greenspline
191
Wessel, P., and D. Bercovici, 1998, Interpolation with splines in tension: a Greens function approach,
Math. Geol., 30, 77-93.
Wessel, P., and J. M. Becker, 2008, Interpolation using a generalized Greens function for a spherical
surface spline in tension, Geophys. J. Int, 174, 21-28.
Wessel, P., 2009, A general-purpose Greens function interpolator, Computers & Geosciences, 35, 12471254, doi:10.1016/j.cageo.2008.08.012.
1.55 isogmt
isogmt - Run GMT command or script in isolation mode
1.55.1 Synopsis
isogmt command
1.55.2 Description
isogmt runs a single GMT command or shell script in isolation mode. This means that the files
gmt.history and gmt.conf will be read from the usual locations (current directory, ~/.gmt, or home directory), but changes will only be written in a temporary directory, which will be removed after execution.
The name of the temporary directory will be available to the command or script as the environment
variable GMT_TMPDIR.
1.55.3 Examples
Run the shell script script.gmt in isolation mode
isogmt sh script.gmt
1.56 kml2gmt
kml2gmt - Extract GMT table data from Google Earth KML files
192
1.56.1 Synopsis
kml2gmt [ kmlfiles ] [ -Fs|l|p ] [ -V[level] ] [ -Z ] [ -bobinary ] [ -donodata ] [ -:[i|o] ]
Note: No space is allowed between the option flag and the associated arguments.
1.56.2 Description
kml2gmt reads a Google Earth KML file and outputs a GMT table file. Only KML files that contain
points, lines, or polygons can be processed. This is a bare-bones operation that aims to extract coordinates and possibly the name and description tags of each feature. The main use intended is to capture
coordinates modified in Google Earth and then reinsert the modified data into the original GMT data
file. For a more complete reformatting, consider using ogr2ogr -f GMT somefile.gmt somefile.kml.
1.56.5 Examples
To extract the lon,lat values from the KML file google.kml, try
gmt kml2gmt google.kml -V > google.txt
To separate the point and polygon geometries from the KML file google.kml, try
gmt kml2gmt google.kml -Fp -V > polygons.txt gmt kml2gmt google.kml -Fs -V >
points.txt
1.56. kml2gmt
193
1.57 makecpt
makecpt - Make GMT color palette tables
1.57.1 Synopsis
makecpt [ -A[+]transparency ] [ -Ccpt ] [ -D[i|o] ] [ -E[nlevels] ] [ -F[R|r|h|c ][+c]] [ -Gzlo/zhi ] [ -I ] [
-M ] [ -N ] [ -Q[i|o] ] [ -Tz_min/z_max[/z_inc[+]] | -Tztable | -Tz1,z2,...,zn ] [ -V[level] ] [ -W ] [ -Z ]
Note: No space is allowed between the option flag and the associated arguments.
1.57.2 Description
makecpt is a utility that will help you make static color palette tables (CPTs). You define an equidistant
set of contour intervals or pass your own z-table or list, and create a new CPT based on an existing
master (dynamic) CPT. The resulting CPT can be reversed relative to the master cpt, and can be made
continuous or discrete. For color tables beyond the standard GMT offerings, visit cpt-city: http://soliton.
vm.bytemark.co.uk/pub/cpt-city/.
The CPT includes three additional colors beyond the range of z-values. These are the background color
(B) assigned to values lower than the lowest z-value, the foreground color (F) assigned to values higher
than the highest z-value, and the NaN color (N) painted wherever values are undefined.
If the master CPT includes B, F, and N entries, these will be copied into the new master file. If not, the
parameters COLOR_BACKGROUND, COLOR_FOREGROUND, and COLOR_NAN from the gmt.conf
file or the command line will be used. This default behavior can be overruled using the options -D, -M
or -N.
The color model (RGB, HSV or CMYK) of the palette created by makecpt will be the same as specified
in the header of the master CPT. When there is no COLOR_MODEL entry in the master CPT, the
COLOR_MODEL specified in the gmt.conf file or on the command line will be used.
-D[i|o] Select the back- and foreground colors to match the colors for lowest and highest z-values in the
output CPT [Default uses the colors specified in the master file, or those defined by the parameters
COLOR_BACKGROUND, COLOR_FOREGROUND, and COLOR_NAN]. Append i to match the
colors for the lowest and highest values in the input (instead of the output) CPT.
-E[nlevels] Implies reading data table(s) from given command-line files or standard input. We use the
last data column to determine the data range; use -i to select another column, and use -bi if your
data table is native binary. This z-range information is used instead of providing the -T option.
We create a linear color table by dividing the table data z-range into nlevels equidistant slices. If
nlevels is not given it defaults to the number of levels in the chosen CPT.
-F[R|r|h|c][+c]] Force output CPT to written with r/g/b codes, gray-scale values or color name (R,
default) or r/g/b codes only (r), or h-s-v codes (h), or c/m/y/k codes (c). Optionally or alternatively,
append +c to write discrete palettes in categorical format.
-Gzlo/zhi Truncate the incoming CPT so that the lowest and highest z-levels are to zlo and zhi. If one of
these equal NaN then we leave that end of the CPT alone. The truncation takes place before any
resampling.
-I Reverses the sense of color progression in the master CPT. Also exchanges the foreground and
background colors, including those specified by the parameters COLOR_BACKGROUND and
COLOR_FOREGROUND.
-M Overrule background, foreground, and NaN colors specified in the master CPT with the values of
the parameters COLOR_BACKGROUND, COLOR_FOREGROUND, and COLOR_NAN specified in the gmt.conf file or on the command line. When combined with -D, only COLOR_NAN is
considered.
-N Do not write out the background, foreground, and NaN-color fields [Default will write them].
-Q[i|o] Selects a logarithmic interpolation scheme [Default is linear]. -Qi expects input z-values to be
log10(z), assigns colors, and writes out z [Default]. -Qo takes log10(z) first, assigns colors, and
writes out z.
-Tz_min/z_max[/z_inc[+]] | -Tztable | -Tz1,z2,...,zn Defines the range of the new CPT by giving the
lowest and highest z-value and interval. Append /z_inc to sample the input CPT discretely at
intervals z_inc between z_min and z_max; append a trailing + to interpret z_inc as the number
of desired intervals instead. Alternatively, give the name of a ASCII file that has one z-value per
record, or provide a list of comma-separated z-values instead If -T is not given, the existing range
in the master CPT will be used intact.
-V[level] (more ...) Select verbosity level [c].
-W Do not interpolate the input color table but pick the output colors starting at the beginning of the
color table, until colors for all intervals are assigned. This is particularly useful in combination
with a categorical color table, like categorical. Cannot be used in combination with -Z.
-Z Creates a continuous CPT [Default is discontinuous, i.e., constant colors for each interval]. This
option has no effect when no -T is used, or when using -Tz_min/z_max; in the first case the input
CPT remains untouched, in the second case it is only scaled to match the range z_min/z_max.
-^ or just - Print a short message about the syntax of the command, then exits (NOTE: on Windows use
just -).
-+ or just + Print an extensive usage (help) message, including the explanation of any module-specific
option (but not the GMT common options), then exits.
1.57. makecpt
195
-? or no arguments Print a complete usage (help) message, including the explanation of options, then
exits.
1.57.8 Examples
To make a CPT with z-values from -200 to 200, with discrete color changes every 25, and using a polar
blue-white-red colortable:
gmt makecpt -Cpolar -T-200/200/25 > colors.cpt
To make an equidistant CPT from z = -2 to 6 using the continuous default rainbow of colors:
gmt makecpt -T-2/6 -Z > rainbow.cpt
To use the GEBCO look-alike CPT with its default range for bathymetry, run
gmt makecpt -Cgebco > my_gebco.cpt
or simply use -Cgebco directly in the application that needs the color table. To create a 24-level rainbow
color table suitable for plotting the depths in the data table depths.txt (with lon, lat, depths), run
gmt makecpt -Cgebco depths.txt -i2 -Z -E24 > my_depths.cpt
196
To make a custom discrete color table for depth of seismicity, using red color for hypocenters between
0 and 100 km, green for 100-300 km, and blue for deep (300-1000 km) earthquakes, use
gmt makecpt -Cred,green,blue -T0,80,300,1000 -N > seis.cpt
Finally, to make a continuous CPT from white to blue as z goes from 3 to 10, try
gmt makecpt -Cwhite,blue -T3,10 -Z > cold.cpt
1.57.9 Bugs
Since makecpt will also interpolate from any existing CPT you may have in your directory, you should
not use one of the listed cpt names as an output filename; hence the my_gebco.cpt in the example. If you
do create a CPT of such a name, e.g., rainbow.cpt, then makecpt will read that file first and not look for
the master CPT in the shared GMT directory.
1.58 mapproject
mapproject - Forward and inverse map transformations, datum conversions and geodesy
1.58.1 Synopsis
mapproject [ tables ] -Jparameters -Rregion [ -Ab|B|f|F|o|O[lon0/lat0] ] [ -C[dx/dy] ] [ -Dc|i|p ] [ E[datum] ] [ -F[unit] ] [ -G[x0/y0/][[+|-]unit][+|-] ] [ -I ] [ -Lline.xy[+u[+|-]unit][+p] ] [ -N[a|c|g|m] ] [
-Q[d|e ] [ -S ] [ -T[h]from[/to] ] [ -V[level] ] [ -W[w|h] ] [ -bbinary ] [ -dnodata ] [ -fflags ] [ -ggaps ] [
-hheaders ] [ -iflags ] [ -oflags ] [ -pflags ] [ -sflags ] [ -:[i|o] ]
Note: No space is allowed between the option flag and the associated arguments.
1.58.2 Description
mapproject reads (longitude, latitude) positions from tables [or standard input] and computes (x,y)
coordinates using the specified map projection and scales. Optionally, it can read (x,y) positions and
compute (longitude, latitude) values doing the inverse transformation. This can be used to transform
linear (x,y) points obtained by digitizing a map of known projection to geographical coordinates. May
also calculate distances along track, to a fixed point, or closest approach to a line. Finally, can be used to
perform various datum conversions. Additional data fields are permitted after the first 2 columns which
must have (longitude,latitude) or (x,y). See option -: on how to read (latitude,longitude) files.
1.58. mapproject
197
-R[unit]xmin/xmax/ymin/ymax[r] (more ...) Specify the region of interest. Special case for the UTM
projection: If -C is used and -R is not given then the region is set to coincide with the given UTM
zone so as to preserve the full ellipsoidal solution (See RESTRICTIONS for more information).
198
1.58.5 Units
For map distance unit, append unit d for arc degree, m for arc minute, and s for arc second, or e for
meter [Default], f for foot, k for km, M for statute mile, n for nautical mile, and u for US survey foot.
By default we compute such distances using a spherical approximation with great circles. Prepend - to
a distance (or the unit is no distance is given) to perform Flat Earth calculations (quicker but less
accurate) or prepend + to perform exact geodesic calculations (slower but more accurate).
1.58. mapproject
199
1.58.7 Examples
To convert UTM coordinates in meters to geographic locations, given a file utm.txt and knowing the
UTM zone (and zone or hemisphere), try
gmt mapproject utm.txt -Ju+11/1:1 -C -I -F
To transform a file with (longitude,latitude) into (x,y) positions in cm on a Mercator grid for a given
scale of 0.5 cm per degree, run
gmt mapproject lonlatfile -R20/50/12/25 -Jm0.5c > xyfile
To transform several 2-column, binary, double precision files with (latitude,longitude) into (x,y) positions in inch on a Transverse Mercator grid (central longitude 75W) for scale = 1:500000 and suppress
those points that would fall outside the map area, run
gmt mapproject tracks.* -R-80/-70/20/40 -Jt-75/1:500000 -: -S -Di -bo -bi2 >
tmfile.b
To convert the geodetic coordinates (lon, lat, height) in the file old.dat from the NAD27 CONUS datum
(Datum ID 131 which uses the Clarke-1866 ellipsoid) to WGS 84, run
gmt mapproject old.dat -Th131 > new.dat
To compute the closest distance (in km) between each point in the input file quakes.dat and the line
segments given in the multisegment ASCII file coastline.xy, run
gmt mapproject quakes.dat -Lcoastline.xy+uk > quake_dist.dat
1.58.8 Restrictions
The rectangular input region set with -R will in general be mapped into a non-rectangular grid. Unless
-C is set, the leftmost point on this grid has xvalue = 0.0, and the lowermost point will have yvalue =
0.0. Thus, before you digitize a map, run the extreme map coordinates through mapproject using the
appropriate scale and see what (x,y) values they are mapped onto. Use these values when setting up for
digitizing in order to have the inverse transformation work correctly, or alternatively, use awk to scale
and shift the (x,y) values before transforming.
For some projection, a spherical solution may be used despite the user having selected an ellipsoid. This
occurs when the users -R setting implies a region that exceeds the domain in which the ellipsoidal series
expansions are valid. These are the conditions: (1) Lambert Conformal Conic (-JL)and Albers EqualArea (-JB) will use the spherical solution when the map scale exceeds 1.0E7. (2) Transverse Mercator
(-JT) and UTM (-JU) will will use the spherical solution when either the west or east boundary given in
200
-R is more than 10 degrees from the central meridian, and (3) same for Cassini (-JC) but with a limit of
only 4 degrees.
1.58.11 References
Bomford, G., 1952, Geodesy, Oxford U. Press.
Snyder, J. P., 1987, Map Projections - A Working Manual, U.S. Geological Survey Prof. Paper 1395.
Vanicek, P. and Krakiwsky, E, 1982, Geodesy - The Concepts, North-Holland Publ., ISBN: 0 444 86149
1.
1.59 nearneighbor
nearneighbor - Grid table data using a Nearest neighbor algorithm
1.59.1 Synopsis
nearneighbor [ table ] -Gout_grdfile -Iincrement -Nsectors[/min_sectors] -Rregion [ Ssearch_radius[unit] [ -Eempty ] [ -V[level] ] [ -W ] [ -bibinary ] [ -dinodata ] [ -fflags ] [
-hheaders ] [ -iflags ] [ -nflags ] [ -r ] [ -:[i|o] ]
1.59. nearneighbor
201
Note: No space is allowed between the option flag and the associated arguments.
1.59.2 Description
nearneighbor reads arbitrarily located (x,y,z[,w]) triples [quadruplets] from standard input [or table]
and uses a nearest neighbor algorithm to assign an average value to each node that have one or more
points within a radius centered on the node. The average value is computed as a weighted mean of the
nearest point from each sector inside the search radius. The weighting function used is w(r) = 1 / (1 + d
^ 2), where d = 3 * r / search_radius and r is distance from the node. This weight is modulated by the
weights of the observation points [if supplied].
-bi[ncols][t] (more ...) Select native binary input. [Default is 3 (or 4 if -W is set) columns].
-dinodata (more ...) Replace input columns that equal nodata with NaN.
-f[i|o]colinfo (more ...) Specify data types of input and/or output columns.
-h[i|o][n][+c][+d][+rremark][+rtitle] (more ...) Skip or produce header record(s).
-icols[l][sscale][ooffset][,...] (more ...) Select input columns (0 is first column).
-n[b|c|l|n][+a][+bBC][+tthreshold] Append +bBC to set any boundary conditions to be used, adding g
for geographic, p for periodic, or n for natural boundary conditions. For the latter two you may
append x or y to specify just one direction, otherwise both are assumed. [Default is geographic if
grid is geographic].
-r (more ...) Set pixel node registration [gridline].
-:[i|o] (more ...) Swap 1st and 2nd column on input and/or output.
-^ or just - Print a short message about the syntax of the command, then exits (NOTE: on Windows use
just -).
-+ or just + Print an extensive usage (help) message, including the explanation of any module-specific
option (but not the GMT common options), then exits.
-? or no arguments Print a complete usage (help) message, including the explanation of options, then
exits.
1.59.5 Units
For map distance unit, append unit d for arc degree, m for arc minute, and s for arc second, or e for
meter [Default], f for foot, k for km, M for statute mile, n for nautical mile, and u for US survey foot.
By default we compute such distances using a spherical approximation with great circles. Prepend - to
a distance (or the unit is no distance is given) to perform Flat Earth calculations (quicker but less
accurate) or prepend + to perform exact geodesic calculations (slower but more accurate).
1.59.7 Examples
To create a gridded data set from the file seaMARCII_bathy.lon_lat_z using a 0.5 min grid, a 5 km search
radius, using an octant search with 100% sector coverage, and set empty nodes to -9999:
gmt nearneighbor seaMARCII_bathy.lon_lat_z -R242/244/-22/-20 -I0.5m \
-E-9999 -Gbathymetry.nc -S5k -N8/8
1.59. nearneighbor
203
To make a global grid file from the data in geoid.xyz using a 1 degree grid, a 200 km search radius,
spherical distances, using an quadrant search, and set nodes to NaN only when fewer than two quadrants
contain at least one value:
gmt nearneighbor geoid.xyz -R0/360/-90/90 -I1 -Lg -Ggeoid.nc -S200k -N4
1.60 project
project - Project table data onto lines or great circles, generate tracks, or translate coordinates
1.60.1 Synopsis
project [ table ] -Ccx/cy [ -Aazimuth ] [ -Ebx/by ] [ -Fflags ] [ -Gdist[/colat][+] ] [ -L[w][l_min/l_max]
] [ -N ] [ -Q ] [ -S ] [ -Tpx/py ] [ -V[level] ] [ -Ww_min/w_max ] [ -bbinary ] [ -dnodata ] [ -fflags ] [
-ggaps ] [ -hheaders ] [ -iflags ] [ -sflags ] [ -:[i|o] ]
Note: No space is allowed between the option flag and the associated arguments.
1.60.2 Description
project reads arbitrary (x, y[,z]) data from standard input [or table ] and writes to standard output any
combination of (x, y, z, p, q, r, s), where (p, q) are the coordinates in the projection, (r, s) is the position in
the (x, y) coordinate system of the point on the profile (q = 0 path) closest to (x, y), and z is all remaining
columns in the input (beyond the required x and y columns).
Alternatively, project may be used to generate (r, s, p) triples at equal increments dist along a profile. In
this case ( -G option), no input is read.
Projections are defined in any (but only) one of three ways:
(Definition 1) By a Center -C and an Azimuth -A in degrees clockwise from North.
(Definition 2) By a Center -C and end point E of the projection path -E.
(Definition 3) By a Center -C and a roTation pole position -T.
To spherically project data along a great circle path, an oblique coordinate system is created which has
its equator along that path, and the zero meridian through the Center. Then the oblique longitude (p) corresponds to the distance from the Center along the great circle, and the oblique latitude (q) corresponds
to the distance perpendicular to the great circle path. When moving in the increasing (p) direction, (toward B or in the azimuth direction), the positive (q) direction is to your left. If a Pole has been specified,
then the positive (q) direction is toward the pole.
To specify an oblique projection, use the -T option to set the Pole. Then the equator of the projection is
already determined and the -C option is used to locate the p = 0 meridian. The Center cx/cy will be taken
as a point through which the p = 0 meridian passes. If you do not care to choose a particular point, use
the South pole (ox = 0, oy = -90).
204
Data can be selectively windowed by using the -L and -W options. If -W is used, the projection Width
is set to use only points with w_min < q < w_max. If -L is set, then the Length is set to use only those
points with l_min < p < l_max. If the -E option has been used to define the projection, then -Lw may be
selected to window the length of the projection to exactly the span from O to B.
Flat Earth (Cartesian) coordinate transformations can also be made. Set -N and remember that azimuth
is clockwise from North (the y axis), NOT the usual cartesian theta, which is counterclockwise from the
x axis. azimuth = 90 - theta.
No assumptions are made regarding the units for x, y, r, s, p, q, dist, l_min, l_max, w_min, w_max. If -Q
is selected, map units are assumed and x, y, r, s must be in degrees and p, q, dist, l_min, l_max, w_min,
w_max will be in km.
Calculations of specific great-circle and geodesic distances or for back-azimuths or azimuths are better
done using mapproject.
project is CASE SENSITIVE. Use UPPER CASE for all one-letter designators which begin optional
arguments. Use lower case for the xyzpqrs letters in -flags.
1.60. project
205
-Tpx/py px/py sets the position of the rotation pole of the projection. (Definition 3).
-V[level] (more ...) Select verbosity level [c].
-Ww_min/w_max Width controls. Project only those points whose q coordinate is within w_min < q <
w_max.
-bi[ncols][t] (more ...) Select native binary input. [Default is 2 input columns].
-bo[ncols][type] (more ...) Select native binary output. [Default is given by -F or -G].
-d[i|o]nodata (more ...) Replace input columns that equal nodata with NaN and do the reverse on output.
-f[i|o]colinfo (more ...) Specify data types of input and/or output columns.
-g[a]x|y|d|X|Y|D|[col]z[+|-]gap[u] (more ...) Determine data gaps and line breaks.
-h[i|o][n][+c][+d][+rremark][+rtitle] (more ...) Skip or produce header record(s).
-icols[l][sscale][ooffset][,...] (more ...) Select input columns (0 is first column).
-s[cols][a|r] (more ...) Set handling of NaN records.
-:[i|o] (more ...) Swap 1st and 2nd column on input and/or output.
-^ or just - Print a short message about the syntax of the command, then exits (NOTE: on Windows use
just -).
-+ or just + Print an extensive usage (help) message, including the explanation of any module-specific
option (but not the GMT common options), then exits.
-? or no arguments Print a complete usage (help) message, including the explanation of options, then
exits.
1.60.6 Examples
To generate points every 10km along a great circle from 10N,50W to 30N,10W:
gmt project -C-50/10 -E-10/30 -G10 -Q > great_circle_points.xyp
(Note that great_circle_points.xyp could now be used as input for grdtrack, etc. ).
To generate points every 10km along a small circle of colatitude 60 from 10N,50W to 30N,10W:
gmt project -C-50/10 -E-10/30 -G10/60 -Q > small_circle_points.xyp
To create a partial small circle of colatitude 80 about a pole at 40E,85N, with extent of 45 degrees to
either side of the meridian defined by the great circle from the pole to a point 15E,15N, try
206
To project the shiptrack gravity, magnetics, and bathymetry in c2610.xygmb along a great circle through
an origin at 30S, 30W, the great circle having an azimuth of N20W at the origin, keeping only the data
from NE of the profile and within +/- 500 km of the origin, run:
gmt project c2610.xygmb -C-30/-30 -A-20 -W-10000/0 -L-500/500 -Fpz -Q > c2610_
projected.pgmb
(Note in this example that -W-10000/0 is used to admit any value with a large negative q coordinate.
This will take those points which are on our right as we walk along the great circle path, or to the NE in
this example.)
To make a Cartesian coordinate transformation of mydata.xy so that the new origin is at 5,3 and the new
x axis (p) makes an angle of 20 degrees with the old x axis, use:
gmt project mydata.xy -C5/3 -A70 -Fpq > mydata.pq
To take data in the file pacific.lonlat and transform it into oblique coordinates using a pole from the
hotspot reference frame and placing the oblique zero meridian (p = 0 line) through Tahiti, run:
gmt project pacific.lonlat -T-75/68 -C-149:26/-17:37 -Fpq > pacific.pq
Suppose that pacific_topo.nc is a grid file of bathymetry, and you want to make a file of flowlines in the
hotspot reference frame. If you run:
gmt grd2xyz pacific_topo.nc | project -T-75/68 -C0/-90 -Fxyq | xyz2grd -Retc Ietc -Cflow.nc
then flow.nc is a file in the same area as pacific_topo.nc, but flow contains the latitudes about the pole of
the projection. You now can use grdcontour on flow.nc to draw lines of constant oblique latitude, which
are flow lines in the hotspot frame.
If you have an arbitrarily rotation pole px/py and you would like to draw an oblique small circle on a
map, you will first need to make a file with the oblique coordinates for the small circle (i.e., lon = 0-360,
lat is constant), then create a file with two records: the north pole (0/90) and the origin (0/0), and find
what their oblique coordinates are using your rotation pole. Now, use the projected North pole and origin
coordinates as the rotation pole and center, respectively, and project your file as in the pacific example
above. This gives coordinates for an oblique small circle.
1.61 psbasemap
psbasemap - Plot PostScript base maps
1.61.1 Synopsis
psbasemap -Jparameters -Rwest/east/south/north[/zmin/zmax][r] [ -B[p|s]parameters ] [ -A[file] ] [ Dinsert box ] [ -Fbox ] [ -K ] [ -Jz|Zparameters ] [ -Lruler ] [ -O ] [ -P ] [ -U[stamp] ] [ -Trose ] [
1.61. psbasemap
207
1.61.2 Description
psbasemap creates PostScript code that will produce a basemap. Several map projections are available,
and the user may specify separate tick-mark intervals for boundary annotation, ticking, and [optionally]
gridlines. A simple map scale or directional rose may also be plotted. At least one of the options -B, -L,
or -T must be specified.
208
logo and border. Append +i to draw a secondary, inner border as well. We use a uniform gap between borders of 2p and the MAP_DEFAULT_PEN unless other values are specified. Append +r
to draw rounded rectangular borders instead, with a 6p corner radius. You can override this radius
by appending another value. Finally, append +s to draw an offset background shaded region. Here,
dx/dy indicates the shift relative to the foreground frame [4p/-4p] and shade sets the fill style to
use for shading [gray50]. Used in combination with -D, -L or -T. To specify separate parameters
for the various map features, append d|l|t to -F to specify panel parameters for just that panel
[Default uses the same panel parameters for all selected map features].
-Jz|Zparameters (more ...) Set z-axis scaling; same syntax as -Jx.
-K (more ...) Do not finalize the PostScript plot.
-L[g|j|J|n|x]refpoint+c[slon/]slat+wlength[e|f|k|M|n|u][+aalign][+f][+l[label]][+u] Draws a simple
map scale centered on the reference point specified using one of four coordinate systems: (1)
Use -Dg for map (user) coordinates, (2) use -Dj or -DJ for setting refpoint via a 2-char justification code that refers to the (invisible) map domain rectangle, (3) use -Dn for normalized (0-1)
coordinates, or (4) use -Dx for plot coordinates (inches, cm, etc.). Scale is calculated for latitude slat (optionally supply longitude slon for oblique projections [Default is central meridian]),
length is in km, or append unit from e|f|k|M|n|u. Change the label alignment with +aalign (choose
among l(eft), r(ight), t(op), and b(ottom)). Append +f to get a fancy scale [Default is plain].
Append +l to select the default label, which equals the distance unit (meter, foot, km, mile, nautical mile, US survey foot) and is justified on top of the scale [t]. Change this by giving your own
label (append +llabel). Select +u to append the unit to all distance annotations along the scale (for
the plain scale, +u will instead select the unit to be appended to the distance length). Note: Use
FONT_LABEL to change the label font and FONT_ANNOT_PRIMARY to change the annotation
font. The height of the map scale is controlled by MAP_SCALE_HEIGHT, and the pen thickness
is set by MAP_TICK_PEN_PRIMARY. See -F on how to place a panel behind the scale.
-O (more ...) Append to existing PostScript plot.
-P (more ...) Select Portrait plot orientation.
-Td[g|j|J|n|x]refpoint+wwidth[+f[level]][+jjustify][+lw,e,s,n][+odx[/dy]] -Td draws a map directional
rose on the map at the location defined by the reference and anchor points: Give the reference point
on the map for the rose using one of four coordinate systems: (1) Use g for map (user) coordinates,
(2) use j for setting refpoint via a 2-char justification code that refers to the (invisible) map domain
rectangle, (3) use n for normalized (0-1) coordinates, or (4) use x for plot coordinates (inches, cm,
etc.) [Default]. You can offset the reference point by dx/dy in the direction implied by justify. By
default, the anchor point on the scale is assumed to be the center of the rose (MC), but this can
be changed by appending +j followed by a 2-char justification code justify (see pstext). Note: If
-Dj is used then justify defaults to the same as refpoint, if -DJ is used then justify defaults to the
mirror opposite of refpoint. Add +o to offset the color scale by dx/dy away from the refpoint point
in the direction implied by justify (or the direction implied by -Dj or -DJ). Append +wwidthto
set the width of the rose in plot coordinates (inches, cm, etc.). Add +f to get a fancy rose,
and specify in level what you want drawn. The default [1] draws the two principal E-W, N-S
orientations, 2 adds the two intermediate NW-SE and NE-SW orientations, while 3 adds the eight
minor orientations WNW-ESE, NNW-SSE, NNE-SSW, and ENE-WSW. Label the cardinal points
W,E,S,N by adding +l and append your own four comma-separated strings to override the default.
See Placing-dir-map-roses and -F on how to place a panel behind the scale.
-Tm[g|j|J|n|x]refpoint+wwidth[+ddec[/dlabel]]][+ipen][+jjustify][+lw,e,s,n][+ppen][+tints][+odx[/dy]]
-Tm draws a map magnetic rose on the map at the location defined by the reference and
anchor points: Give the reference point on the map for the rose using one of four coordinate
1.61. psbasemap
209
systems: (1) Use g for map (user) coordinates, (2) use j for setting refpoint via a 2-char
justification code that refers to the (invisible) map domain rectangle, (3) use n for normalized (0-1) coordinates, or (4) use x for plot coordinates (inches, cm, etc.) [Default]. You can
offset the reference point by dx/dy in the direction implied by justify. By default, the anchor
point on the scale is assumed to be the center of the rose (MC), but this can be changed
by appending +j followed by a 2-char justification code justify (see pstext). Note: If -Dj is
used then justify defaults to the same as refpoint, if -DJ is used then justify defaults to the
mirror opposite of refpoint. Add +o to offset the color scale by dx/dy away from the refpoint
point in the direction implied by justify (or the direction implied by -Dj or -DJ). Append
+wwidthto set the width of the rose in plot coordinates (inches, cm, etc.). Use +d to assign
the magnetic declination and set dlabel, which is a label for the magnetic compass needle
(Leave empty to format a label from dec, or give - to bypass labeling). With +d, both directions to geographic and magnetic north are plotted [Default is geographic only]. If the north
label is * then a north star is plotted instead of the north label. Annotation and two levels of
tick intervals for both geographic and magnetic directions are 30/5/1 degrees; override these
settings by appending +tints, and append six intervals to set both the geographic and magnetic intervals. Label the cardinal points W,E,S,N by adding +l and append your own four
comma-separated strings to override the default. Number GMT default parameters control
pens, fonts, and color; see the Placing-mag-map-roses section in the Cookbook. See -F on
how to place a panel behind the scale.
-U[just/dx/dy/][c|label] (more ...) Draw GMT time stamp logo on plot.
-V[level] (more ...) Select verbosity level [c].
-X[a|c|f|r][x-shift[u]]
-Y[a|c|f|r][y-shift[u]] (more ...) Shift plot origin.
-ccopies (more ...) Specify number of plot copies [Default is 1].
-f[i|o]colinfo (more ...) Specify data types of input and/or output columns. This applies only to the coordinates specified in the -R option.
-p[x|y|z]azim/elev[/zlevel][+wlon0/lat0[/z0]][+vx0/y0] (more ...) Select perspective view.
-t[transp] (more ...) Set PDF transparency level in percent.
-^ or just - Print a short message about the syntax of the command, then exits (NOTE: on Windows use
just -).
-+ or just + Print an extensive usage (help) message, including the explanation of any module-specific
option (but not the GMT common options), then exits.
-? or no arguments Print a complete usage (help) message, including the explanation of options, then
exits.
1.61.5 Examples
The following section illustrates the use of the options by giving some examples for the available map
projections. Note how scales may be given in several different ways depending on the projection. Also
note the use of upper case letters to specify map width instead of map scale.
210
Log-log plot
To make a log-log frame with only the left and bottom axes, where the x-axis is 25 cm and annotated
every 1-2-5 and the y-axis is 15 cm and annotated every power of 10 but has tick-marks every 0.1, run
gmt psbasemap -R1/10000/1e20/1e25 -JX25cl/15cl -Bx2+lWavelength -Bya1pf3+lPower BWS > loglog.ps
Power axes
To design an axis system to be used for a depth-sqrt(age) plot with depth positive down, ticked and
annotated every 500m, and ages annotated at 1 my, 4 my, 9 my etc, use
gmt psbasemap -R0/100/0/5000 -Jx1p0.5/-0.001 -Bx1p+l"Crustal age" -By500+lDepth >
power.ps
Mercator [conformal]
A Mercator map with scale 0.025 inch/degree along equator, and showing the length of 5000 km along
the equator (centered on 1/1 inch), may be plotted as
gmt psbasemap -R90/180/-50/50 -Jm0.025i -Bafg -B+tMercator -Lx1i/1i+c0+w5000k >
mercator.ps
1.61. psbasemap
211
Miller
A global Miller cylindrical map with scale 1:200,000,000 may be plotted as
gmt psbasemap -Rg -Jj180/1:200000000 -Bafg -B+tMiller > miller.ps
Cylindrical Equal-Area
First select which of the cylindrical equal-area projections you want by deciding on the standard parallel.
Here we will use 45 degrees which gives the Gall-Peters projection. A 9 inch wide global basemap
centered on the Pacific is made by
gmt psbasemap -Rg -JY180/45/9i -Bafg -B+tGall-Peters > gall-peters.ps
Lambert [conformal]
Another basemap for middle Europe may be created by
gmt psbasemap -R0/90/25/55 -Jl45/20/32/45/0.1i -Bafg -B+t"Lambert Conformal Conic
" > lambertc.ps
Equidistant
Yet another basemap of width 6 inch for middle Europe may be created by
gmt psbasemap -R0/90/25/55 -JD45/20/32/45/6i -Bafg -B+t"Equidistant conic" >
econic.ps
Polyconic
A basemap for north America may be created by
gmt psbasemap -R-180/-20/0/90 -JPoly/4i -Bafg -B+tPolyconic > polyconic.ps
Follow the instructions for stereographic projection if you want to impose rectangular boundaries on the
azimuthal equal-area map but substitute -Ja for -Js.
Equidistant
A 15-cm-wide global map in which distances from the center (here 125/10) to any point is true can be
obtained by:
gmt psbasemap -Rg -JE125/10/15c -Bafg -B+tEquidistant > equi.ps
Gnomonic
A view of the world from the vantage point -100/40 out to a horizon of 60 degrees from the center can
be made using the Gnomonic projection:
gmt psbasemap -Rg -JF-100/40/60/6i -Bafg -B+tGnomonic > gnomonic.ps
1.61. psbasemap
213
Orthographic
A global perspective (from infinite distance) view of the world from the vantage point 125/10 will give
the following 6-inch-wide basemap:
gmt psbasemap -Rg -JG125/10/6i -Bafg -B+tOrthographic > ortho.ps
General Perspective
The -JG option can be used in a more generalized form, specifying altitude above the surface, width
and height of the view point, and twist and tilt. A view from 160 km above -74/41.5 with a tilt of 55
and azimuth of 210 degrees, and limiting the viewpoint to 30 degrees width and height will product a
6-inch-wide basemap:
gmt psbasemap -Rg -JG-74/41.5/160/210/55/30/30/6i -Bafg -B+t"General Perspective"
> genper.ps
Stereographic [conformal]
To make a polar stereographic projection basemap with radius = 12 cm to -60 degree latitude, with plot
title Salinity measurements, using 5 degrees annotation/tick interval and 1 degree gridlines, run
gmt psbasemap -R-45/45/-90/-60 -Js0/-90/12c/-60 -B5g1 -B+t"Salinity measurements"
> stereo1.ps
To make a 12-cm-wide stereographic basemap for Australia from an arbitrary view point (not the poles),
and use a rectangular boundary, we must give the pole for the new projection and use the -R option to
indicate the lower left and upper right corners (in lon/lat) that will define our rectangle. We choose a
pole at 130/-30 and use 100/-45 and 160/-5 as our corners. The command becomes
gmt psbasemap -R100/-45/160/-5r -JS130/-30/12c -Bafg -B+t"General Stereographic
View" > stereo2.ps
Sinusoidal [equal-area]
To make a sinusoidal world map centered on Greenwich, with a scale along the equator of 0.02
inch/degree, use
gmt psbasemap -Rd -Ji0/0.02i -Bafg -B+tSinusoidal > sinus1.ps
To make an interrupted sinusoidal world map with breaks at 160W, 20W, and 60E, with a scale along
the equator of 0.02 inch/degree, run the following sequence of commands:
214
Eckert IV [equal-area]
Pseudo-cylindrical projection typically used for global maps only. Set the central longitude and scale,
e.g.,
gmt psbasemap -Rg -Jkf180/0.064c -Bafg -B+t"Eckert IV" > eckert4.ps
Eckert VI [equal-area]
Another pseudo-cylindrical projection typically used for global maps only. Set the central longitude and
scale, e.g.,
gmt psbasemap -Rg -Jks180/0.064c -Bafg -B+t"Eckert VI" > eckert6.ps
Robinson
Projection designed to make global maps look right. Set the central longitude and width, e.g.,
gmt psbasemap -Rd -JN0/8i -Bafg -B+tRobinson > robinson.ps
Winkel Tripel
Yet another projection typically used for global maps only. You can set the central longitude, e.g.,
gmt psbasemap -R90/450/-90/90 -JR270/25c -Bafg -B+t"Winkel Tripel" > winkel.ps
Mollweide [equal-area]
The Mollweide projection is also mostly used for global maps and thus the spherical form is used. To
get a 25-cm-wide world map centered on the Dateline:
psbasemap -Rg -JW180/25c -Bafg -B+tMollweide > mollweide.ps
1.61. psbasemap
215
1.61.12 Restrictions
For some projections, a spherical earth is implicitly assumed. A warning will notify the user if -V is set.
1.61.13 Bugs
The -B option is somewhat complicated to explain and comprehend. However, it is fairly simple for most
applications (see examples).
1.62 psclip
psclip - Initialize or terminate polygonal clip paths
1.62.1 Synopsis
psclip [ table ] -Jparameters -C[n] -Rwest/east/south/north[/zmin/zmax][r] [ -A[m|p|x|y] ] [ B[p|s]parameters ] -Jz|Zparameters ] [ -K ] [ -N ] [ -O ] [ -P ] [ -T ] [ -U[stamp] ] [ -V[level] ] [
-Xx_offset ] [ -Yy_offset ] [ -bibinary ] [ -ccopies ] [ -dinodata ] [ -fflags ] [ -ggaps ] [ -hheaders ] [
-iflags ] [ -pflags ] [ -ttransp ] [ -:[i|o] ]
Note: No space is allowed between the option flag and the associated arguments.
1.62.2 Description
psclip reads (x,y) file(s) [or standard input] and draws polygons that are activated as clipping paths.
Several files may be read to create complex paths consisting of several non-connecting segments. Only
marks that are subsequently drawn inside the clipping path will be shown. To determine what is inside
or outside the clipping path, psclip uses the even-odd rule. When a ray drawn from any point, regardless
of direction, crosses the clipping path segments an odd number of times, the point is inside the clipping
path. If the number is even, the point is outside. The -N option, reverses the sense of what is the inside
and outside of the paths by plotting a clipping path along the map boundary. After subsequent plotting,
216
which will be clipped against these paths, the clipping may be deactivated by running psclip a second
time with the -C option only.
1.62. psclip
217
-f[i|o]colinfo (more ...) Specify data types of input and/or output columns.
-g[a]x|y|d|X|Y|D|[col]z[+|-]gap[u] (more ...) Determine data gaps and line breaks.
-h[i|o][n][+c][+d][+rremark][+rtitle] (more ...) Skip or produce header record(s).
-icols[l][sscale][ooffset][,...] (more ...) Select input columns (0 is first column).
-p[x|y|z]azim/elev[/zlevel][+wlon0/lat0[/z0]][+vx0/y0] (more ...) Select perspective view.
-t[transp] (more ...) Set PDF transparency level in percent.
-:[i|o] (more ...) Swap 1st and 2nd column on input and/or output.
-^ or just - Print a short message about the syntax of the command, then exits (NOTE: on Windows use
just -).
-+ or just + Print an extensive usage (help) message, including the explanation of any module-specific
option (but not the GMT common options), then exits.
-? or no arguments Print a complete usage (help) message, including the explanation of options, then
exits.
1.62.5 Examples
To make an overlay PostScript file that will set up a complex clip area to which subsequent plotting will
be confined, run:
gmt psclip my_region.xy -R0/40/0/40 -Jm0.3i -O -K > clip_mask_on.ps
1.63 pscoast
pscoast - Plot continents, shorelines, rivers, and borders on maps
1.63.1 Synopsis
pscoast -Jparameters -Rregion [ -Aarea ] [ -B[p|s]parameters ] [ -C[l|r/]fill ] [ -Dresolution[+] ] [ -Edcw
] [ -Fbox ] [ -Gfill|c ] [ -Iriver[/pen] ] [ -Jz|Zparameters ] [ -K ] [ -Lruler ] [ -M ] [ -Nborder[/pen] ]
[ -O ] [ -P ] [ -Q ] [ -Sfill|c ] [ -Trose ] [ -Tmag_rose ] [ -U[stamp] ] [ -V[level] ] [ -W[level/]pen ] [
-Xx_offset ] [ -Yy_offset ] [ -bobinary ] [ -ccopies ] [ -pflags ] [ -ttransp ]
Note: No space is allowed between the option flag and the associated arguments.
218
1.63.2 Description
pscoast plots grayshaded, colored, or textured land-masses [or water-masses] on maps and [optionally]
draws coastlines, rivers, and political boundaries. Alternatively, it can (1) issue clip paths that will contain all land or all water areas, or (2) dump the data to an ASCII table. The data files come in 5 different
resolutions: (f)ull, (h)igh, (i)ntermediate, (l)ow, and (c)rude. The full resolution files amount to more
than 55 Mb of data and provide great detail; for maps of larger geographical extent it is more economical to use one of the other resolutions. If the user selects to paint the land-areas and does not specify fill
of water-areas then the latter will be transparent (i.e., earlier graphics drawn in those areas will not be
overwritten). Likewise, if the water-areas are painted and no land fill is set then the land-areas will be
transparent. A map projection must be supplied. The PostScript code is written to standard output.
219
-Dresolution[+] Selects the resolution of the data set to use ((f)ull, (h)igh, (i)ntermediate, (l)ow, and
(c)rude). The resolution drops off by 80% between data sets [Default is l]. Append + to automatically select a lower resolution should the one requested not be available [abort if not found].
Alternatively, choose (a)uto to automatically select the best resolution given the chosen map scale.
-Ecode1,code2,...[+l|L][+gfill][+ppen][+r|R[incs]] Select painting or dumping country polygons from
the Digital Chart of the World. This is another dataset independent of GSHHG and hence the
-A and -D options do not apply. Append one or more comma-separated countries using the 2character ISO 3166-1 alpha-2 convention. To select a state of a country (if available), append .state,
e.g, US.TX for Texas. To specify a whole continent, prepend = to any of the continent codes AF
(Africa), AN (Antarctica), AS (Asia), EU (Europe), OC (Oceania), NA (North America), or SA
(South America). Append +l to just list the countries and their codes [no data extraction or plotting
takes place]. Use +L to see states/territories for Argentina, Australia, Brazil, Canada, and the US.
Use +r to obtain the bounding box coordinates from the polygon(s). Append inc, xinc/yinc, or
winc/einc/sinc/ninc to adjust the region to be a multiple of these steps [no adjustment]. Use +R to
extend the region outward by adding these increments instead [no extension]. Append +ppen to
draw polygon outlines [no outline] and +gfill to fill them [no fill]. One of +p|g must be specified
unless +r, +R, or -M is in effect, and only one -E option can be given. You may repeat -E to give
different groups of items separate pen/fill settings. If modifiers +r or +R are used and neither -J
nor -M is set then we just print the -Rwesn string.
-F[+cclearances][+gfill][+i[[gap/]pen]][+p[pen]][+r[radius]][+s[[dx/dy/][shade]]] Without
further
options, draws a rectangular border around the map scale or rose using MAP_FRAME_PEN;
specify a different pen with +ppen. Add +gfill to fill the logo box [no fill]. Append +cclearance
where clearance is either gap, xgap/ygap, or lgap/rgap/bgap/tgap where these items are uniform,
separate in x- and y-direction, or individual side spacings between logo and border. Append +i
to draw a secondary, inner border as well. We use a uniform gap between borders of 2p and the
MAP_DEFAULT_PEN unless other values are specified. Append +r to draw rounded rectangular
borders instead, with a 6p corner radius. You can override this radius by appending another value.
Finally, append +s to draw an offset background shaded region. Here, dx/dy indicates the shift
relative to the foreground frame [4p/-4p] and shade sets the fill style to use for shading [gray50].
Requires -L or -T. If both -L or -T, you may repeat -F after each of these.
-Gfill|c Select filling or clipping of dry areas. Append the shade, color, or pattern; or use -Gc for
clipping [Default is no fill].
-Iriver[/pen] Draw rivers. Specify the type of rivers and [optionally] append pen attributes [Default pen:
width = default, color = black, style = solid].
Choose from the list of river types below; repeat option -I as often as necessary.
0 = Double-lined rivers (river-lakes)
1 = Permanent major rivers
2 = Additional major rivers
3 = Additional rivers
4 = Minor rivers
5 = Intermittent rivers - major
6 = Intermittent rivers - additional
7 = Intermittent rivers - minor
8 = Major canals
220
9 = Minor canals
10 = Irrigation canals
You can also choose from several preconfigured river groups:
a = All rivers and canals (0-10)
A = All rivers and canals except river-lakes (1-10)
r = All permanent rivers (0-4)
R = All permanent rivers except river-lakes (1-4)
i = All intermittent rivers (5-7)
c = All canals (8-10)
-Jz|Zparameters (more ...) Set z-axis scaling; same syntax as -Jx.
-K (more ...) Do not finalize the PostScript plot.
-L[g|j|J|n|x]refpoint+c[slon/]slat+wlength[e|f|k|M|n|u][+aalign][+f][+l[label]][+u] Draws a simple
map scale centered on the reference point specified using one of four coordinate systems: (1)
Use -Dg for map (user) coordinates, (2) use -Dj or -DJ for setting refpoint via a 2-char justification code that refers to the (invisible) map domain rectangle, (3) use -Dn for normalized (0-1)
coordinates, or (4) use -Dx for plot coordinates (inches, cm, etc.). Scale is calculated for latitude slat (optionally supply longitude slon for oblique projections [Default is central meridian]),
length is in km, or append unit from e|f|k|M|n|u. Change the label alignment with +aalign (choose
among l(eft), r(ight), t(op), and b(ottom)). Append +f to get a fancy scale [Default is plain].
Append +l to select the default label, which equals the distance unit (meter, foot, km, mile, nautical mile, US survey foot) and is justified on top of the scale [t]. Change this by giving your own
label (append +llabel). Select +u to append the unit to all distance annotations along the scale (for
the plain scale, +u will instead select the unit to be appended to the distance length). Note: Use
FONT_LABEL to change the label font and FONT_ANNOT_PRIMARY to change the annotation
font. The height of the map scale is controlled by MAP_SCALE_HEIGHT, and the pen thickness
is set by MAP_TICK_PEN_PRIMARY. See -F on how to place a panel behind the scale.
-M Dumps a single multisegment ASCII (or binary, see -bo) file to standard output. No plotting occurs.
Specify one of -E, -I, -N or -W. Note: if -M is used with -E then -R or the +r modifier to -E are
not required as we automatically determine the region given the selected geographic entities.
-Nborder[/pen] Draw political boundaries. Specify the type of boundary and [optionally] append pen
attributes [Default pen: width = default, color = black, style = solid].
Choose from the list of boundaries below. Repeat option -N as often as necessary.
1 = National boundaries
2 = State boundaries within the Americas
3 = Marine boundaries
a = All boundaries (1-3)
-O (more ...) Append to existing PostScript plot.
-P (more ...) Select Portrait plot orientation.
-Q Mark end of existing clip path. No projection information is needed. Also supply -X and -Y settings
if you have moved since the clip started.
1.63. pscoast
221
-Sfill|c Select filling or clipping of wet areas. Append the shade, color, or pattern; or use -Sc for
clipping [Default is no fill].
-Td[g|j|J|n|x]refpoint+wwidth[+f[level]][+jjustify][+lw,e,s,n][+odx[/dy]] -Td draws a map directional
rose on the map at the location defined by the reference and anchor points: Give the reference point
on the map for the rose using one of four coordinate systems: (1) Use g for map (user) coordinates,
(2) use j for setting refpoint via a 2-char justification code that refers to the (invisible) map domain
rectangle, (3) use n for normalized (0-1) coordinates, or (4) use x for plot coordinates (inches, cm,
etc.) [Default]. You can offset the reference point by dx/dy in the direction implied by justify. By
default, the anchor point on the scale is assumed to be the center of the rose (MC), but this can
be changed by appending +j followed by a 2-char justification code justify (see pstext). Note: If
-Dj is used then justify defaults to the same as refpoint, if -DJ is used then justify defaults to the
mirror opposite of refpoint. Add +o to offset the color scale by dx/dy away from the refpoint point
in the direction implied by justify (or the direction implied by -Dj or -DJ). Append +wwidthto
set the width of the rose in plot coordinates (inches, cm, etc.). Add +f to get a fancy rose,
and specify in level what you want drawn. The default [1] draws the two principal E-W, N-S
orientations, 2 adds the two intermediate NW-SE and NE-SW orientations, while 3 adds the eight
minor orientations WNW-ESE, NNW-SSE, NNE-SSW, and ENE-WSW. Label the cardinal points
W,E,S,N by adding +l and append your own four comma-separated strings to override the default.
See Placing-dir-map-roses and -F on how to place a panel behind the scale.
-Tm[g|j|J|n|x]refpoint+wwidth[+ddec[/dlabel]]][+ipen][+jjustify][+lw,e,s,n][+ppen][+tints][+odx[/dy]]
-Tm draws a map magnetic rose on the map at the location defined by the reference and
anchor points: Give the reference point on the map for the rose using one of four coordinate
systems: (1) Use g for map (user) coordinates, (2) use j for setting refpoint via a 2-char
justification code that refers to the (invisible) map domain rectangle, (3) use n for normalized (0-1) coordinates, or (4) use x for plot coordinates (inches, cm, etc.) [Default]. You can
offset the reference point by dx/dy in the direction implied by justify. By default, the anchor
point on the scale is assumed to be the center of the rose (MC), but this can be changed
by appending +j followed by a 2-char justification code justify (see pstext). Note: If -Dj is
used then justify defaults to the same as refpoint, if -DJ is used then justify defaults to the
mirror opposite of refpoint. Add +o to offset the color scale by dx/dy away from the refpoint
point in the direction implied by justify (or the direction implied by -Dj or -DJ). Append
+wwidthto set the width of the rose in plot coordinates (inches, cm, etc.). Use +d to assign
the magnetic declination and set dlabel, which is a label for the magnetic compass needle
(Leave empty to format a label from dec, or give - to bypass labeling). With +d, both directions to geographic and magnetic north are plotted [Default is geographic only]. If the north
label is * then a north star is plotted instead of the north label. Annotation and two levels of
tick intervals for both geographic and magnetic directions are 30/5/1 degrees; override these
settings by appending +tints, and append six intervals to set both the geographic and magnetic intervals. Label the cardinal points W,E,S,N by adding +l and append your own four
comma-separated strings to override the default. Number GMT default parameters control
pens, fonts, and color; see the Placing-mag-map-roses section in the Cookbook. See -F on
how to place a panel behind the scale.
-U[just/dx/dy/][c|label] (more ...) Draw GMT time stamp logo on plot.
-V[level] (more ...) Select verbosity level [c].
-W[level/]pen (more ...) Draw shorelines [Default is no shorelines]. Append pen attributes [Defaults:
width = default, color = black, style = solid] which apply to all four levels. To set the pen for each
level differently, prepend level/, where level is 1-4 and represent coastline, lakeshore, island-inlake shore, and lake-in-island-in-lake shore. Repeat -W as needed. When specific level pens are
222
set, those not listed will not be drawn [Default draws all levels; but see -A].
-X[a|c|f|r][x-shift[u]]
-Y[a|c|f|r][y-shift[u]] (more ...) Shift plot origin.
-bo[ncols][type] (more ...) Select native binary output.
-ccopies (more ...) Specify number of plot copies [Default is 1].
-p[x|y|z]azim/elev[/zlevel][+wlon0/lat0[/z0]][+vx0/y0] (more ...) Select perspective view.
-t[transp] (more ...) Set PDF transparency level in percent.
-^ or just - Print a short message about the syntax of the command, then exits (NOTE: on Windows use
just -).
-+ or just + Print an extensive usage (help) message, including the explanation of any module-specific
option (but not the GMT common options), then exits.
-? or no arguments Print a complete usage (help) message, including the explanation of options, then
exits.
1.63.5 Examples
To plot a green Africa with white outline on blue background, with permanent major rivers in thick blue
pen, additional major rivers in thin blue pen, and national borders as dashed lines on a Mercator map at
scale 0.1 inch/degree, use
gmt pscoast -R-30/30/-40/40 -Jm0.1i -B5 -I1/1p,blue -N1/0.25p,- \
-I2/0.25p,blue -W0.25p,white -Ggreen -Sblue -P > africa.ps
To plot Iceland using the lava pattern (# 28) at 100 dots per inch, on a Mercator map at scale 1 cm/degree,
run
gmt pscoast -R-30/-10/60/65 -Jm1c -B5 -Gp100/28 > iceland.ps
To initiate a clip path for Africa so that the subsequent colorimage of gridded topography is only seen
over land, using a Mercator map at scale 0.1 inch/degree, use
gmt pscoast -R-30/30/-40/40 -Jm0.1i -B5 -Gc -P -K > africa.ps
gmt grdimage -Jm0.1i etopo5.nc -Ccolors.cpt -O -K >> africa.ps
gmt pscoast -Q -O >> africa.ps
To plot Great Britain, Italy, and France in blue with a red outline and Spain, Portugal and Greece in
yellow (no outline), and pick up the plot domain form the extents of these countries, use
gmt pscoast
ps
To extract a high-resolution coastline data table for Iceland to be used in your analysis, try
gmt pscoast -R-26/-12/62/68 -Dh -W -M > iceland.txt
pscoast will first look for coastline files in directory $GMT_SHAREDIR/coast If the desired file is not
found, it will look for the file $GMT_SHAREDIR/coastline.conf. This file may contain any number of
records that each holds the full pathname of an alternative directory. Comment lines (#) and blank lines
are allowed. The desired file is then sought for in the alternate directories.
1.63. pscoast
223
1.63.7 Bugs
The options to fill (-C -G -S) may not always work if the Azimuthal equidistant projection is chosen
(-Je|E). If the antipole of the projection is in the oceans it will most likely work. If not, try to avoid using
projection center coordinates that are even multiples of the coastline bin size (1, 2, 5, 10, and 20 degrees
for f, h, i, l, c, respectively). This projection is not supported for clipping.
The political borders are for the most part 1970s-style but have been updated to reflect more recent
border rearrangements in Europe and elsewhere. Let us know if you find something out of date.
The full-resolution coastlines are also from a digitizing effort in the 1970-80s and it is difficult to assess
the accuracy. Users who zoom in close enough may find that the GSHHG coastline is not matching other
data, e.g., satellite images, more recent coastline data, etc. We are aware of such mismatches but cannot
undertake band-aid solutions each time this occurs.
Some users of pscoast will not be satisfied with what they find for the Antarctic shoreline. In Antarctica, the boundary between ice and ocean varies seasonally and inter-annually. There are some areas
of permanent shelf ice. In addition to these time-varying ice-ocean boundaries, there are also shelf ice
grounding lines where ice goes from floating on the sea to sitting on land, and lines delimiting areas of
rock outcrop. For consistencys sake, we have used the World Vector Shoreline throughout the world
in pscoast, as described in the GMT Cookbook Appendix K. Users who need specific boundaries in
Antarctica should get the Antarctic Digital Database, prepared by the British Antarctic Survey, Scott
Polar Research Institute, World Conservation Monitoring Centre, under the auspices of the Scientific
Committee on Antarctic Research. This data base contains various kinds of limiting lines for Antarctica
and is available on CD-ROM. It is published by the Scientific Committee on Antarctic Research, Scott
Polar Research Institute, Lensfield Road, Cambridge CB2 1ER, United Kingdom.
1.64 pscontour
pscontour - Contour table data by direct triangulation [method]
224
1.64.1 Synopsis
pscontour [ table ] -C[+]cpt -Jparameters -Rwest/east/south/north[/zmin/zmax][r] [ -A[|[+]annot_int][labelinfo] ] [ -B[p|s]parameters ] [ -D[template] ] [ -Eindexfile ] [ -G[d|f|n|l|L|x|X]params
] [ -I ] [ -Jz|Zparameters ] [ -K ] [ -Lpen ] [ -N ] [ -O ] [ -P ] [ -Qcut ] [ -S[p|t] ] [ -T[+|][+dgap[/length]][+l[labels]] ] [ -U[stamp] ] [ -V[level] ] [ -W[type]pen ][+c[l|f]] [ -Xx_offset ] [
-Yy_offset ] [ -bbinary ] [ -ccopies ] [ -hheaders ] [ -iflags ] [ -pflags ] [ -ttransp ] [ -:[i|o] ]
Note: No space is allowed between the option flag and the associated arguments.
1.64.2 Description
pscontour reads an ASCII [or binary] table and produces a raw contour plot by triangulation. By default,
the optimal Delaunay triangulation is performed (using either Shewchuks [1996] or Watsons [1982]
method as selected during GMT installation; type pscontour - to see which method is selected), but the
user may optionally provide a second file with network information, such as a triangular mesh used for
finite element modeling. In addition to contours, the area between contours may be painted according to
the CPT. Alternatively, the x/y/z positions of the contour lines may be saved to one or more output files
(or stdout) and no plot is produced.
1.64. pscontour
225
controls how many files are created and how the contours are organized. If the float format
%f is present (standard modifications to width and precision are allowed, e.g., %f7.3f), then
the filenames will contain the contour value and lines are thus separated into files based on
a common contour value. If the integer format %d is present (including modifications like
%05d), then all contours are written to individual segment files; if any of the other specifiers
are present they just affect the file names. Finally, if the character format %c is present it is
replaced with the letters C (for closed) or O (for open), reflecting the nature of each contour.
Any combination of one, two, or all three modifiers are valid, resulting in different filenames
and number of files. For instance, if %c appears by itself, then only two files are created,
separating the open from the closed contours (assuming both kinds are present). If just %f is
used, then all segments for the same contour level will be written to the same file, resulting
in N multi-segment files. If both %f and %c were combined then each contour level would
be further subdivided into closed and open contours. Any combination involving %d will
result in one individual file for each segment; %c, %f only modifies the file names. The files
are ASCII unless -bo is used.
-Eindexfile Give name of file with network information. Each record must contain triplets of node
numbers for a triangle [Default computes these using Delaunay triangulation (see triangulate)].
-G
The required argument controls the placement of labels along the quoted lines. Choose
among five controlling algorithms:
ddist[c|i|p] or Ddist[d|e|f|k|m|M|n|s] For lower case d, give distances between labels on
the plot in your preferred measurement unit c (cm), i (inch), or p (points), while for
upper case D, specify distances in map units and append the unit; choose among e
(m), f (foot), k (km), M (mile), n (nautical mile) or u (US survey foot), and d (arc
degree), m (arc minute), or s (arc second). [Default is 10c or 4i]. As an option, you
can append /fraction which is used to place the very first label for each contour when
the cumulative along-contour distance equals fraction * dist [0.25].
fffile.d Reads the ASCII file ffile.d and places labels at locations in the file that matches
locations along the quoted lines. Inexact matches and points outside the region are
skipped.
l|Lline1[,line2,...] Give start and stop coordinates for one or more comma-separated
straight line segments. Labels will be placed where these lines intersect the quoted
lines. The format of each line specification is start/stop, where start and stop are either a specified point lon/lat or a 2-character XY key that uses the justification format
employed in pstext to indicate a point on the map, given as [LCR][BMT]. In addition,
you can use Z-, Z+ to mean the global minimum and maximum locations in the grid.
L will interpret the point pairs as defining great circles [Default is straight line].
nn_label Specifies the number of equidistant labels for quoted lines line [1]. Upper case N
starts labeling exactly at the start of the line [Default centers them along the line]. N-1
places one justified label at start, while N+1 places one justified label at the end of
quoted lines. Optionally, append /min_dist[c|i|p] to enforce that a minimum distance
separation between successive labels is enforced.
x|Xxfile.d Reads the multisegment file xfile.d and places labels at the intersections between
the quoted lines and the lines in xfile.d. X will resample the lines first along great-circle
arcs.
In addition, you may optionally append +rradius[c|i|p] to set a minimum label separation
in the x-y plane [no limitation].
1.64. pscontour
227
228
-^ or just - Print a short message about the syntax of the command, then exits (NOTE: on Windows use
just -).
-+ or just + Print an extensive usage (help) message, including the explanation of any module-specific
option (but not the GMT common options), then exits.
-? or no arguments Print a complete usage (help) message, including the explanation of options, then
exits.
1.64.5 Examples
To make a raw contour plot from the file topo.xyz and drawing the contours (pen = 2) given in the CPT
topo.cpt on a Lambert map at 0.5 inch/degree along the standard parallels 18 and 24, use
gmt pscontour topo.xyz -R320/330/20/30 -Jl18/24/0.5i -Ctopo.cpt -W0.5p > topo.ps
To create a color PostScript plot of the numerical temperature solution obtained on a triangular mesh
whose node coordinates and temperatures are stored in temp.xyz and mesh arrangement is given by the
file mesh.ijk, using the colors in temp.cpt, run
gmt pscontour temp.xyz -R0/150/0/100 -Jx0.1i -Ctemp.cpt -G -W0.25p > temp.ps
To save the triangulated 100-m contour lines in topo.txt and separate them into multisegment files (one
for each contour level), try
gmt pscontour topo.txt -C100 -Dcontours_%.0f.txt
1.64.7 References
Watson, D. F., 1982, Acord: Automatic contouring of raw data, Comp. & Geosci., 8, 97-101.
Shewchuk, J. R., 1996, Triangle: Engineering a 2D Quality Mesh Generator and Delaunay Triangulator,
First Workshop on Applied Computational Geometry (Philadelphia, PA), 124-133, ACM, May 1996.
http://www.cs.cmu.edu/~quake/triangle.html
1.65 psconvert
psconvert - Convert [E]PS file(s) to other formats using GhostScript
1.65.1 Synopsis
psconvert psfile(s) [ -Aparams ] [ -Cgs_option ] [ -Doutdir ] [ -Eresolution ] [ -Fout_name ] [ Gghost_path ] [ -I ] [ -Llistfile ] [ -P ] [ -Q[g|t][1|2|4] ] [ -S ] [ -Tb|e|E|f|F|j|g|G|m|s|t ] [ -V[level] ]
[ -Wparams ] [ -Z ]
1.65. psconvert
229
Note: No space is allowed between the option flag and the associated arguments.
1.65.2 Description
psconvert converts one or more PostScript files to other formats (BMP, EPS, JPEG, PDF, PNG, PPM,
SVG, TIFF) using GhostScript. Input file names are read from the command line or from a file that lists
them. The size of the resulting images is determined by the BoundingBox (or HiResBoundingBox, if
present). As an option, a tight (HiRes)BoundingBox may be computed first. As another option, it can
compute ESRI type world files used to reference, for instance, tif files and make them be recognized
as geotiff. Note: If the PostScript file calls on any of the Adobe PDF transparency extensions and PDF
is not the selected output format, then the file will first be converted to a temporary PDF file (for the
transparency to take effect) before converting the PDF to the desired output format.
230
-Gghost_path Full path to your GhostScript executable. NOTE: For Unix systems this is generally not necessary. Under Windows, the GhostScript path is now fetched from the registry. If
this fails you can still add the GS path to systems path or give the full path here. (e.g., Gc:\programs\gs\gs9.02\bin\gswin64c). WARNING: because of the poor decision of embedding
the bits on the gs exe name we cannot satisfy both the 32 and 64 bits GhostScript executable
names. So in case of get from registry failure the default name (when no -G is used) is the one
of the 64 bits version, or gswin64c
-I Enforce gray-shades by using ICC profiles. GhostScript versions >= 9.00 change gray-shades by using ICC profiles. GhostScript 9.05 and above provide the -dUseFastColor=true option to prevent
that and that is what psconvert does by default, unless option -I is set. Note that for GhostScript
>= 9.00 and < 9.05 the gray-shade shifting is applied to all but PDF format. We have no solution
to offer other than upgrade GhostScript.
-Llistfile The listfile is an ASCII file with the names of the PostScript files to be converted.
-N This option is obsolete. Use -S to print the GhostScript command, if applicable. Use -Te to save the
intermediate EPS file.
-P Force Portrait mode. All Landscape mode plots will be rotated back so that they show unrotated in
Portrait mode. This is practical when converting to image formats or preparing EPS or PDF plots
for inclusion in documents.
-Q[g|t][1|2|4] Set the anti-aliasing options for graphics or text. Append the size of the subsample box
(1, 2, or 4) [4]. Default is no anti-aliasing (same as bits = 1).
-S Print to standard error the GhostScript command after it has been executed. This option also prevent
all intermediate files from being removed.
-Tb|e|E|f|F|j|g|G|m|s|t Sets the output format, where b means BMP, e means EPS, E means EPS with
PageSize command, f means PDF, F means multi-page PDF, j means JPEG, g means PNG, G
means transparent PNG (untouched regions are transparent), m means PPM, s means SVG, and t
means TIFF [default is JPEG]. To bjgt you can append - in order to get a grayscale image. The
EPS format can be combined with any of the other formats. For example, -Tef creates both an EPS
and a PDF file. The -TF creates a multi-page PDF file from the list of input PS or PDF files. It
requires the -F option. See also NOTES below.
-V[level] (more ...) Select verbosity level [c].
-W[+g][+k][+tdocname][+nlayername][+ofoldername][+aaltmode[alt]][+lminLOD/maxLOD][+fminfade/maxfade][+
Write a ESRI type world file suitable to make (e.g) .tif files be recognized as geotiff
by software that know how to do it. Be aware, however, that different results are obtained depending on the image contents and if the -B option has been used or not. The
trouble with the -B option is that it creates a frame and very likely its annotations. That
introduces pixels outside the map data extent, and therefore the map extents estimation
will be wrong. To avoid this problem use --MAP_FRAME_TYPE=inside option which
plots all annotations and ticks inside the image and therefore does not compromise the
coordinate computations. Pay attention also to the cases when the plot has any of the
sides with whites only because than the algorithm will fail miserably as those whites
will be eaten by the GhostScript. In that case you really must use -B or use a slightly
off-white color.
Together with -V it prints on screen the gdal_translate (gdal_translate is a command
line tool from the GDAL package) command that reads the raster + world file and
1.65. psconvert
231
creates a true geotiff file. Use -W+g to do a system call to gdal_translate and create a
geoTIFF image right away. The output file will have a .tiff extension.
The world file naming follows the convention of jamming a w in the file extension.
So, if output is tif -Tt the world file is a .tfw, for jpeg we have a .jgw and so on. This
option automatically sets -A -P.
Use -W+k to create a minimalist KML file that allows loading the image in
GoogleEarth. Note that for this option the image must be in geographical coordinates. If not, a warning is issued but the KML file is created anyway. Several modifier options are available to customize the KML file in the form of +opt strings. Append +ttitle to set the document title [GMT KML Document], +nlayername to set
the layer name, and +a/altmode[altitude] to select one of 5 altitude modes recognized by Google Earth that determines the altitude (in m) of the image: G clamped
to the ground, g append altitude relative to ground, a append absolute altitude, s append altitude relative to seafloor, and S clamp it to the seafloor. Control visibility of
the layer with the +lminLOD/maxLOD and +fminfade/maxfade options. Finally, if you
plan to leave the image itself on a server and only distribute the KML, use +uURL to
prepend the URL to the image reference. If you are building a multi-component KML
file then you can issue a KML snipped without the KML header and trailer by using
the +ofoldername modification; it will enclose the image and associated KML code
within a KML folder of the specified name. See the KML documentation for further
explanation (http://code.google.com/apis/kml/documentation/).
Further notes on the creation of georeferenced rasters. psconvert can create a georeferenced raster image with a world file OR uses GDAL to convert the GMT PostScript
file to geotiff. GDAL uses Proj.4 for its projection library. To provide with the information it needs to do the georeferencing, GMT 4.5 embeds a comment near the start
of the PostScript file defining the projection using Proj.4 syntax. Users with pre-GMT
v4.5 PostScript files, or even non-GMT ps files, can provide the information psconvert
requires by manually editing a line into the PostScript file, prefixed with %%PROJ.
For example the command
gmt pscoast -JM0/12c -R-10/-4/37/43 -W1 -Di -Bg30m --MAP_FRAME_TYPE=inside > cara.ps
adds this comment line
-Z Remove the input PostScript file(s) after the conversion. The input file(s) will not be removed in case
of failures.
-^ or just - Print a short message about the syntax of the command, then exits (NOTE: on Windows use
just -).
-+ or just + Print an extensive usage (help) message, including the explanation of any module-specific
option (but not the GMT common options), then exits.
-? or no arguments Print a complete usage (help) message, including the explanation of options, then
exits.
232
1.65.5 Notes
The conversion to raster images (BMP, JPEG, PNG, PPM or TIFF) inherently results in loss of details
that are available in the original PostScript file. Choose a resolution that is large enough for the application that the image will be used for. For web pages, smaller dpi values suffice, for Word documents and
PowerPoint presentations a higher dpi value is recommended. psconvert uses the loss-less DEFLATE
compression technique when creating PDF and PNG files and LZW compression for TIFF images. For
smaller dpi images, such as required for building animations, the use of -Qt4 and -Qg4 may help sharpen
text and lines.
EPS is a vector (not a raster) format. Therefore, the -E option has no effect on the creation of EPS files.
Using the option -Te will remove setpagedevice commands from the PostScript file and will adjust the
BoundingBox when the -A option is used. Note the original and required BoundingBox is limited to
integer points, hence Adobe added the optional HiResBoundingBox to add more precision in sizing.
The -A option calculates both and writes both to the EPS file and is subsequently used in any rasterization, if requested. When the -TE* option is used, a new setpagedevice command is added that
will indicate the actual pagesize for the plot, similar to the BoundingBox. Note that when the command setpagedevice exists in a PostScript file that is included in another document, this can wreak
havoc on the printing or viewing of the overall document. Hence, **-TE should only be used for
standalone PostScript files.
Although PDF and SVG are also vector formats, the -E option has an effect on the resolution of pattern
fills and fonts that are stored as bitmaps in the document. psconvert therefore uses a larger default
resolution when creating PDF and SVG files. -E also determines the resolution of the boundingbox
values used to indicate the size of the output PDF. In order to obtain high-quality PDF or SVG files,
the /prepress options are in effect, allowing only loss-less DEFLATE compression of raster images
embedded in the PostScript file.
Although psconvert was developed as part of the GMT, it can be used to convert PostScript files created
by nearly any graphics program. However, -Au is GMT-specific.
The ghostscript program continues to be developed and occasionally its developers make decisions
that affect psconvert. As of version 9.16 the SVG device has been removed. Fortunately, quality SVG
graphics can be obtained by first converting to PDF and then install and use the package pdf2svg.
See include-gmt-graphics of the GMT Technical Reference and Cookbook for more information on
how psconvert is used to produce graphics that can be inserted into other documents (articles, presentations, posters, etc.).
1.65.6 Examples
To convert the file psfile.ps to PNG using a tight BoundingBox and rotating it back to normal orientation
in case it was in Landscape mode:
gmt psconvert psfile.ps -A -P -Tg
To convert the file map.ps to PDF, extend the BoundingBox by 0.2 cm, fill it with lightblue paint and
draw outline with a thick pen:
gmt psconvert map.ps -A0.2c+glightblue+pthick -Tf
1.65. psconvert
233
To create a simple linear map with pscoast and convert it to tif with a .tfw the tight BoundingBox
computation.
gmt pscoast -JX12cd -R-10/-4/37/43 -W1 -Di -Bg30m -P -G200 --MAP_FRAME_
TYPE=inside > cara.ps
gmt psconvert cara.ps -Tt -W
To create a Mercator version of the above example and use GDAL to produce a true geotiff file.
gmt pscoast -JM0/12c -R-10/-4/37/43 -W1 -Di -Bg30m -P -G200 --MAP_FRAME_
TYPE=inside > cara.ps
gdalwarp -s_srs +proj=merc cara.tif carageo.tiff
(These commands assume that GhostScript can be found in your systems path.)
1.66 pshistogram
pshistogram - Calculate and plot histograms
234
1.66.1 Synopsis
pshistogram [ table ] -Jx|Xparameters -Wbin_width[+l|h|b] [ -A ] [ -B[p|s]parameters ] [ -Ccpt ]
[ -D[+b][+ffont][+ooff ][+r] ] [ -F ] [ -Gfill ] [ -Jz|Zparameters ] [ -I[o|O] ] [ -K ] [ -Lpen ] [ N[mode][+ppen] ] [ -O ] [ -P ] [ -Q ] [ -Rregion ] [ -S ] [ -U[stamp] ] [ -V[level] ] [ -Xx_offset ] [
-Yy_offset ] [ -Ztype ] [ -bibinary ] [ -ccopies ] [ -dinodata ] [ -fflags ] [ -hheaders ] [ -iflags ] [ -pflags
] [ -ttransp ]
Note: No space is allowed between the option flag and the associated arguments.
1.66.2 Description
pshistogram reads file [or standard input] and examines the first data column (or use -i) to calculate
histogram parameters based on the bin-width provided. Using these parameters, scaling, and optional
range parameters it will generate PostScript code that plots a histogram. A cumulative histogram may
also be specified.
1.66. pshistogram
235
-Lpen Draw bar outline using the specified pen thickness. [Default is no outline].
-N[mode][+ppen] Draw the equivalent normal distribution; append desired pen [0.5p,black]. The mode
selects which central location and scale to use:
0 = mean and standard deviation [Default];
1 = median and L1 scale;
2 = LMS mode and scale.
The -N option may be repeated to draw several of these curves.
-O (more ...) Append to existing PostScript plot.
-P (more ...) Select Portrait plot orientation.
-Q Draw a cumulative histogram.
-R[unit]xmin/xmax/ymin/ymax[r] (more ...) Specify the region of interest.
For perspective view p, optionally append /zmin/zmax. (more ...) If not given, pshistogram will automatically find reasonable values for the region.
-S Draws a stairs-step diagram which does not include the internal bars of the default histogram.
-U[just/dx/dy/][c|label] (more ...) Draw GMT time stamp logo on plot.
-V[level] (more ...) Select verbosity level [c].
-X[a|c|f|r][x-shift[u]]
-Y[a|c|f|r][y-shift[u]] (more ...) Shift plot origin.
-Ztype Choose between 6 types of histograms:
0 = counts [Default]
1 = frequency_percent
2 = log (1.0 + count)
3 = log (1.0 + frequency_percent)
4 = log10 (1.0 + count)
5 = log10 (1.0 + frequency_percent).
-bi[ncols][t] (more ...) Select native binary input. [Default is 2 input columns].
-ccopies (more ...) Specify number of plot copies [Default is 1].
-dinodata (more ...) Replace input columns that equal nodata with NaN.
-f[i|o]colinfo (more ...) Specify data types of input and/or output columns.
-h[i|o][n][+c][+d][+rremark][+rtitle] (more ...) Skip or produce header record(s).
-icols[l][sscale][ooffset][,...] (more ...) Select input columns (0 is first column).
-p[x|y|z]azim/elev[/zlevel][+wlon0/lat0[/z0]][+vx0/y0] (more ...) Select perspective view.
-t[transp] (more ...) Set PDF transparency level in percent.
-^ or just - Print a short message about the syntax of the command, then exits (NOTE: on Windows use
just -).
236
-+ or just + Print an extensive usage (help) message, including the explanation of any module-specific
option (but not the GMT common options), then exits.
-? or no arguments Print a complete usage (help) message, including the explanation of options, then
exits.
1.66.5 Examples
To draw a histogram of the data v3206.t containing seafloor depths, using a 250 meter bin width, center
bars, and draw bar outline, use:
gmt pshistogram v3206.t -JXh -W250 -F -LP0.5p -V > plot.ps
If you know the distribution of your data, you may explicitly specify range and scales. E.g., to plot a
histogram of the y-values (2nd column) in the file errors.xy using a 1 meter bin width, plot from -10 to
+10 meters @ 0.75 cm/m, annotate every 2 m and 100 counts, and use black bars, run:
gmt pshistogram errors.xy -W1 -R-10/10/0/0 -Jxc/0.01c \
-Bx2+lError -By100+lCounts: -Gblack -i1 -V > plot.ps
Since no y-range was specified, pshistogram will calculate ymax in even increments of 100.
1.66.6 Bugs
The -W option does not yet work properly with time series data (e.g., -f0T). Thus, such variable intervals
as months and years are not calculated. Instead, specify your interval in the same units as the current
setting of TIME_UNIT.
1.67 psimage
psimage - Place images or EPS files on maps
1.67.1 Synopsis
psimage imagefile [ -Drefpoint ] [ -Fbox ] [ -G[b|f|t]color ] [ -I ] [ -Jparameters ] [ -Jz|Zparameters ] [
-K ] [ -M ] [ -O ] [ -P ] [ -Rwest/east/south/north[/zmin/zmax][r] ] [ -U[stamp] ] [ -V[level] ] [ -Xx_offset
] [ -Yy_offset ] [ -ccopies ] [ -pflags ] [ -ttransp ]
Note: No space is allowed between the option flag and the associated arguments.
1.67.2 Description
psimage reads an Encapsulated PostScript file or a raster image file and plots it on a map. The image can
be scaled arbitrarily, and 1-bit raster images can be (1) inverted, i.e., black pixels (on) becomes white
(off) and vice versa, or (2) colorized, by assigning different foreground and background colors, and (3)
1.67. psimage
237
made transparent where one of back- or foreground is painted only. As an option, the user may choose to
convert colored raster images to grayscale using TVs YIQ-transformation. For raster files, the user can
select which color to be made transparent. The user may also choose to replicate the image which, when
preceded by appropriate clip paths, may allow larger custom-designed fill patterns to be implemented
(the -Gp mechanism offered in most GMT programs is limited to rasters smaller than 146 by 146).
To include an Encapsulated PostScript file tiger.eps with its upper right corner 2 inch to the right and 1
inch up from the current location, and have its width scaled to 3 inches, while keeping the aspect ratio,
use
gmt psimage tiger.eps -Dx2i/1i+jTR+w3i > image.ps
1.67. psimage
239
To replicate the 1-bit raster image template 1_bit.ras, colorize it (brown background and red foreground),
and setting each of 5 by 5 tiles to be 1 cm wide, use
gmt psimage 1_bit.ras -Gbbrown -Gfred -Dx0/0+w1c+n5 > image.ps
1.68 pslegend
pslegend - Plot legends on maps
1.68.1 Synopsis
pslegend [ specfile ] -Drefpoint ] [ -Cdx/dy ] [ -Fbox ] [ -Jparameters ] [ -K ] [ -O ] [ -P ] [ -Rregion ] [
-U[stamp] ] [ -V[level] ] [ -Xx_offset ] [ -Yy_offset ] [ -ccopies ] [ -pflags ] [ -ttransp ]
Note: No space is allowed between the option flag and the associated arguments.
1.68.2 Description
pslegend will make legends that can be overlaid on maps. It reads specific legend-related information
from an input file [or stdin]. Unless otherwise noted, annotations will be made using the primary annotation font and size in effect (i.e., FONT_ANNOT_PRIMARY)
240
-F[+cclearances][+gfill][+i[[gap/]pen]][+p[pen]][+r[radius]][+s[[dx/dy/][shade]]] Without
further
options, draws a rectangular border around the legend using MAP_FRAME_PEN; specify a
different pen with +ppen. Add +gfill to fill the legend box [no fill]. Append +cclearance where
clearance is either gap, xgap/ygap, or lgap/rgap/bgap/tgap where these items are uniform,
separate in x- and y-direction, or individual side spacings between scale and border. Append +i
to draw a secondary, inner border as well. We use a uniform gap between borders of 2p and
the MAP_DEFAULTS_PEN unless other values are specified. Append +r to draw rounded
rectangular borders instead, with a 6p corner radius. You can override this radius by appending
another value. Finally, append +s to draw an offset background shaded region. Here, dx/dy
indicates the shift relative to the foreground frame [4p/-4p] and shade sets the fill style to use for
shading [gray50].
-Jparameters (more ...) Select map projection.
-K (more ...) Do not finalize the PostScript plot.
-O (more ...) Append to existing PostScript plot.
-P (more ...) Select Portrait plot orientation.
-R[unit]xmin/xmax/ymin/ymax[r] (more ...) Specify the region of interest.
-U[just/dx/dy/][c|label] (more ...) Draw GMT time stamp logo on plot.
-V[level] (more ...) Select verbosity level [c].
-X[a|c|f|r][x-shift[u]]
-Y[a|c|f|r][y-shift[u]] (more ...) Shift plot origin.
-ccopies (more ...) Specify number of plot copies [Default is 1].
-p[x|y|z]azim/elev[/zlevel][+wlon0/lat0[/z0]][+vx0/y0] (more ...) Select perspective view.
-t[transp] (more ...) Set PDF transparency level in percent.
-^ or just - Print a short message about the syntax of the command, then exits (NOTE: on Windows use
just -).
-+ or just + Print an extensive usage (help) message, including the explanation of any module-specific
option (but not the GMT common options), then exits.
-? or no arguments Print a complete usage (help) message, including the explanation of options, then
exits.
1.68. pslegend
241
B cptname offset height [ optional arguments ] The B record will plot a horizontal color bar,
psscale-style in the middle, starting at offset from the left edge, and of the given
height. You may add any additional psscale options as well. Any of the modifiers
[+e[b|f][<length>]][+h][+ma|c|l|u][+n[<txt>]] may be appended to the height argument, while
other module options -B -I -L -M -N -S -Z and -p may be appended as optional arguments at
the end of the record. See psscale for details on all modifiers and options.
C textcolor The C record specifies the color with which the remaining text is to be printed. textcolor
can be in the form r/g/b, c/m/y/k, a named color, or an indirect color via z=*value* (requires the
A command). Use - to reset to default color.
D [offset] pen [-|+|=] The D record results in a horizontal line with specified pen across the legend with
one quarter of the line-spacing left blank above and below the line. Two gaps of offset units are
left blank between the horizontal line and the left and right frame sides [0]. If no pen is given
we use MAP_GRID_PEN_PRIMARY, and if pen is set to - then no visible line is drawn (we just
remember the location as a possible start/stop point for a vertical line; see V). To not add the
quarter line-spacing before the line, add -. To not add the spacing after the line, add +. For no
spacing at all, add = [Default places a quarter line-spacing both before and after the line].
F fill1 fill2 ... filln Specify fill (color of pattern) for cells. Alternatively, you can specify an indirect color
via z=*value* (requires the A command). If only fill1 is given then it is used to fill the entire row,
otherwise give one fill value for each active column (see N). If any fill is - then no fill takes place
[Default].
G gap The G record specifies a vertical gap of the given length. In addition to the standard units (i, c, p)
you may use l for lines. A negative gap will move the current line upwards (thus closing a gap).
H fontsize|- font|- header The H record plots a centered text string using the specified font parameters.
Use - to default to size and type of FONT_TITLE.
I imagefile width justification Place an EPS or raster image in the legend justified relative to the current
point. The image width determines the size of the image on the page.
L fontsize|- font|- justification label The L record plots a (L)eft, (C)entered, or (R)ight-justified text
string within a column using the specified font parameters. Use - to default to the size and type of
FONT_LABEL.
M slon|- slat length [+f][+l[label]][+u] [-Fparam] [ -Rw/e/s/n -Jparam ] Place a map scale in the legend. Specify slon slat, the point on the map where the scale applies (slon is only meaningful for
certain oblique projections. If not needed, you must specify - instead). Give length, the length of
the scale in km (for other units append e (meter), f (foot), M (mile), n (nautical mile), or u (survey
foot)). Append +f for a fancy map scale [Default is plain]. Append +l to the length to select the
default label which equals the distance unit (meter, feet, km, miles, nautical miles, survey feet)
and is justified on top of the scale [t]. Change this by giving your own label (append +llabel).
Change label alignment with +aalign (choose among l(eft), r(ight), t(op) , and b(ottom)). Apply
+u to append the unit to all distance annotations along the scale. If you want to place a map panel
behind the scale, add a suitable -F panel option (see psbasemap for details on panels as well as
map scale modifiers). All +modifiers must be appended to length to make a single string argument.
If the -R -J supplied to pslegend is different than the projection needed for the scale (or not given
at all, e.g., with -Dx), supply the two optional -R -J settings as well.
N [ncolumns or relwidth1 relwidth2 ... relwidthn] Change the number of columns in the legend [1].
This only affects the printing of symbols (S) and labels (L). The number of columns stay in effect
until N is used again. To get columns of unequal width, instead provide the relative width of each
column separated by whitespace. The sum of these widths are equated to the legend width set via
-D. If no argument is given the we set n_columns to 1.
242
1.68.6 Defaults
When attributes are not provided, or extended symbol information (for symbols taking more than just an
overall size) are not given as comma-separated quantities, pslegend will provide the following defaults:
Front: Front symbol is left-side (here, that means upper side) box, with dimensions 30% of the given
symbol size.
Vector: Head size is 30% of given symbol size.
Ellipse: Minor axis is 65% of major axis (the symbol size), with an azimuth of 0 degrees.
Rectangle: Height is 65% of width (the symbol size).
Rotated rectangle: Same, with a rotation of 30 degrees.
Rounded rectangle: Same as rectangle, but with corner radius of 10% of width.
Mathangle: Angles are -10 and 45 degrees, with arrow head size 30% of symbol size.
Wedge: Angles are -30 and 30 degrees.
1.68. pslegend
243
1.68.7 Examples
To add an example of a legend to a Mercator plot (map.ps) with the given specifications, use
gmt pslegend -R-10/10/-10/10 -JM6i -F+gazure1 -Dx0.5i/0.5i+w5i/3.3i+jBL+l1.2 \
-C0.1i/0.1i -B5f1 << EOF >> map.ps
# Legend test for pslegend
# G is vertical gap, V is vertical line, N sets # of columns, D draws horizontal
line.
# H is header, L is label, S is symbol, T is paragraph text, M is map scale.
#
G -0.1i
H 24 Times-Roman My Map Legend
D 0.2i 1p
N 2
V 0 1p
S 0.1i c 0.15i p300/12 0.25p 0.3i This circle is hachured
S 0.1i e 0.15i yellow 0.25p 0.3i This ellipse is yellow
S 0.1i w 0.15i green 0.25p 0.3i This wedge is green
S 0.1i f0.1i+l+t 0.25i blue 0.25p 0.3i This is a fault
S 0.1i - 0.15i - 0.25p,- 0.3i A dashed contour
S 0.1i v0.1i+a40+e 0.25i magenta 0.25p 0.3i This is a vector
S 0.1i i 0.15i cyan 0.25p 0.3i This triangle is boring
V 0 1p
D 0.2i 1p
N 1
M 5 5 600+u f
G 0.05i
I SOEST_logo.ras 3i CT
G 0.05i
B colors.cpt 0.2i 0.2i
G 0.05i L 9 4 R Smith et al., @%5%J. Geophys. Res., 99@%%, 2000
G 0.1i
P
T Let us just try some simple text that can go on a few lines.
T There is no easy way to predetermine how many lines will be required,
T so we may have to adjust the box height to get the right size box.
EOF
244
1.69 postscriptlight
PSL 5.1 - A PostScript based plotting library
1.69.1 Description
PSL (PostScriptLight) was created to make the generation of PostScript page description code easier. PS
is a page description language developed by the Adobe for specifying how a printer should render a page
of text or graphics. It uses a reverse Polish notation that puts and gets items from a stack to draws lines,
text, and images and even performs calculations. PSL is a self-contained library that presents a series
of functions that can be used to create plots. The resulting PostScript code is ASCII text (with some
exceptions for images if so desired) and can thus be edited using any text editor. Thus, it is possible to
modify a plot file even after it has been created, e.g., to change text strings, set new gray shades or colors,
experiment with various pen widths, etc. Furthermore, various tools exist that can parse PostScript and
let you make such edits via a graphical user interface (e.g., Adobe Illustrator). PSL is written in C
but includes FORTRAN bindings and can therefore be called from both C and FORTRAN programs.
To use this library, you must link your plotting program with PSL. PSL is used by the GMT graphics
programs to generate PS. PSL output is freeform PostScript that conforms to the Adobe PostScript File
Specification Version 3.0.
Before any PSL calls can be issued, the plotting system must be initialized. This is done by calling
PSL_beginsession, which initializes a new PSL session; then call PSL_setdefaults which sets internal
variables and default settings, accepts settings for measurement units and character encoding, and returns
a pointer to a struct PSL_CTRL which must be passed as first argument to all other PSL functions. The
measure unit for sizes and positions can be set to be centimeter (c), inch (i), meter (m), or points (p).
A PSL session is terminated by calling PSL_endsession. You may create one or more plots within the
same session. A new plot is started by calling PSL_beginplot, which defines macros, sets up the plotcoordinate system, scales, and [optionally] opens a file where all the PS code will be written. Normally,
the plot code is written to stdout. When all plotting to this file is done, you finalize the plot by calling
PSL_endplot.
A wide variety of output devices that support PostScript exist, including many printers and large-format
plotters. Many tools exists to display PostScript on a computer screen. Open source tools such as
ghostscript can be used to convert PostScript into PDF or raster images (e.g., TIFF, JPEG) at a userdefined resolution (DPI). In particular, the GMT tool psconvert is a front-end to ghostscript and preselects the optimal options for ghostscript that will render quality PDF and images.
The PSL is fully 64-bit compliant. Integer parameters are here specified by the type long to distinguish
them from the 32-bit int. Note that under standard 32-bit compilation they are equivalent. Users of
this library under 64-bit mode must make sure they pass proper long variables (under Unix flavors) or
__int64 under Windows 64.
1.69.2 Units
PSL can be instructed to use centimeters, inches, meters or points as input units for the coordinates and
sizes of elements to be plotted. Any dimension that takes this setting as a unit is specified as user units or
plot units in this manual. Excluded from this are line widths and font sizes which are always measured in
points. The user units can be further refined by calling PSL_beginaxes, giving the user the opportunity
to specify any linear coordinate frame. Changing the coordinate frame only affects the coordinates of
plotted material indicated as measured in plot units, not the sizes of symbols (which remain in user
units), nor line widths or font sizes (which remain in points).
1.69. postscriptlight
245
1.69.3 Color
PSL uses the direct color model where red, green, and blue are given separately, each must be in the
range from 0-1. If red = -1 then no fill operation takes place. If red = -3, then pattern fill will be used,
and the green value will indicate the pattern to be used. Most plot-items can be plotted with or without
outlines. If outline is desired (i.e., set to 1), it will be drawn using the current line width and pattern. PSL
uses highly optimized macro substitutions and scales the coordinates depending on the resolution of the
hardcopy device so that the output file is kept as compact as possible.
1.69.4 Justification
Text strings, text boxes and images can be justified by specifying the corner to which the x and y
coordinates of the subroutine call apply. Nine different values are possible, as shown schematically in
this diagram:
910 11 | | 5 6 7 | | 1 2 3
The box represents the text or image. E.g., to plot a text string with its center at (x, y), you must use justify == 6. justify == 0 means no justification, which generally means (x, y) is at the bottom left. Convenience values PSL_NONE, PSL_BL, PSL_BC, PSL_BL, PSL_ML, PSL_MC, PSL_MR, PSL_TL,
PSL_TC and PSL_TR are available.
1.69.5 Initialization
These functions initialize or terminate the PSL system. We use the term PSL session to indicate one
instance of the PSL system (a complicated program could run many PSL sessions concurrently as each
would operate via its own control structure). During a single session, one or more plots may be created.
Here are the functions involved in initialization:
struct PSL_CTRL *New_PSL_Ctrl (char *session)
This is the first function that must be called as it creates a new PSL session. Specifically, it
will allocate a new PSL control structure and initialize the session default parameters. The
pointer that is returned must be passed to all subsequent PSL functions.
long *PSL_beginsession (struct PSL_CTRL *PSL, long search, char *sharedir, char *userdir)
This is the second function that must be called as it initializes the new PSL session. Here,
search is an integer that is passed as 0 in GMT but should be 1 for other users. If so we will
search for the environmental parameters PSL_SHAREDIR and PSL_USERDIR should the
corresponding arguments sharedir and userdir be NULL.
long PSL_endsession (struct PSL_CTRL *PSL)
This function terminates the active PSL session; it is the last function you must call in your
program. Specifically, this function will deallocate memory used and free up resources.
struct PSL_CTRL *PSL_beginlayer (struct PSL_CTRL *PSL, long layer)
Adds a DSC comment by naming this layer; give a unique integer value. Terminate layer
with PSL_endlayer
struct PSL_CTRL *PSL_endlayer (struct PSL_CTRL *PSL)
Terminate current layer with a DSC comment.
246
1.69. postscriptlight
247
Terminates the plotting sequence and closes plot file (if other than stdout). If last_page ==
PSL_FINALIZE (1), then a PostScript showpage command is issued, which initiates the
printing process on hardcopy devices. Otherwise, pass PSL_OVERLAY (0).
long PSL_setorigin (struct PSL_CTRL *P, double xorigin, double yorigin, double angle, long mode)
Changes the coordinate system by translating by (xorigin,yorigin) followed by a angledegree rotation (mode=PSL_FWD or 0) or alternatively the rotation followed by translation
(mode=PSL_INV or 1).
248
Sets up the specified image pattern as the fill to use for polygons and symbols. Here, image_no is the number of the standard PSL fill patterns (1-90; use a negative number when
you specify an image filename instead. The scaling (i.e., resolution in dots per inch) of the
pattern is controlled by the image dpi; if set to 0 it will be plotted at the device resolution.
The two remaining settings apply to 1-bit images only and are otherwise ignored: You may
replace the foreground color (the set bits) with the f_rgb color and the background color (the
unset bits) with b_rgb. Alternatively, pass either color with the red component set to -1.0
and we will instead issue an image mask that is see-through for the specified fore- or background component. To subsequently use the pattern as a pen or fill color, use PSL_setcolor
or DB(PSL_setfill) with the a color rgb code made up of r = -3, and b = the pattern number
returned by PSL_setpattern.
long PSL_setdash (struct PSL_CTRL *P, char *pattern, double offset)
Changes the current pen style attributes. The character string pattern contains the desired
pattern using a series of lengths in points specifying the alternating lengths of dashes and
gaps in points. E.g., 4 2 and offset = 1 will plot like
x - - where x is starting point of a line (The x is not plotted). That is, the line is made up of a
repeating pattern of a 4 points long solid line and a 2 points long gap, starting 1 point after
the x. To reset to solid line, specify pattern = NULL () and offset = 0.
long PSL_setfill (struct PSL_CTRL *P, double rgb[], long outline)
Sets the current fill color and whether or not outline is needed for symbols. Special cases
are handled by passing the red color as -1.0 (no fill), -2.0 (do not change the outline setting)
or -3.0 (select the image pattern indicated by the second (green) element of rgb). For PDF
transparency, set rgb[3] to a value between 0 (opaque) and 1 (fully transparent). Set outline
to PSL_OUTLINE (1) to draw the outlines of polygons and symbols using the current pen.
long PSL_setfont (struct PSL_CTRL *P, long fontnr)
Changes the current font number to fontnr. The fonts available are: 0 = Helvetica, 1 =
H. Bold, 2 = H. Oblique, 3 = H. Bold-Oblique, 4 = Times, 5 = T. Bold, 6 = T. Italic,
7 = T. Bold Italic, 8 = Courier, 9 = C. Bold, 10 = C Oblique, 11 = C Bold Oblique,
12 = Symbol, 13 = AvantGarde-Book, 14 = A.-BookOblique, 15 = A.-Demi, 16 = A.DemiOblique, 17 = Bookman-Demi, 18 = B.-DemiItalic, 19 = B.-Light, 20 = B.-LightItalic,
21 = Helvetica-Narrow, 22 = H-N-Bold, 23 = H-N-Oblique, 24 = H-N-BoldOblique, 25
= NewCenturySchlbk-Roman, 26 = N.-Italic, 27 = N.-Bold, 28 = N.-BoldItalic, 29 =
Palatino-Roman, 30 = P.-Italic, 31 = P.-Bold, 32 = P.-BoldItalic, 33 = ZapfChanceryMediumItalic, 34 = ZapfDingbats, 35 = Ryumin-Light-EUC-H, 36 = Ryumin-Light-EUCV, 37 = GothicBBB-Medium-EUC-H, and 38 = GothicBBB-Medium-EUC-V. If fontnr is
outside this range, it is reset to 0.
long PSL_setfontdims (struct PSL_CTRL *P, double supsub, double scaps, double sup, double
sdown)
Changes the settings for a variety of relative font sizes and shifts pertaining to sub-scripts,
super-scripts, and small caps. Default settings are given in brackets. Here, supsub sets the
relative size of sub- and super-scripts [0.58], scaps sets the relative size of small caps [0.8],
sup indicates the upward baseline shift for placement of super-scripts [0.33], while sdown
sets the downward baseline shift for sub-scripts [0.33].
long PSL_setformat (struct PSL_CTRL *P, long n_decimals)
1.69. postscriptlight
249
Sets the number of decimals to be used when writing color or gray values. The default
setting of 3 gives 1000 choices per red, green, and blue value, which is more than the 255
choices offered by most 24-bit platforms. Choosing a lower value will make the output file
smaller at the expense of less color resolution. Still, a value of 2 gives 100 x 100 x 100 =
1 million colors, more than most eyes can distinguish. For a setting of 1, you will have 10
nuances per primary color and a total of 1000 unique combinations.
long PSL_setlinewidth (struct PSL_CTRL *P, double linewidth)
Changes the current line width in points. Specifying 0 gives the thinnest line possible, but
this is implementation-dependent (seems to work fine on most PostScript printers).
long PSL_setlinecap (struct PSL_CTRL *P, long cap)
Changes the current line cap, i.e., what happens at the beginning and end of a line segment.
PSL_BUTT_CAP (0) gives butt line caps [Default], PSL_ROUND_CAP (1) selects round
caps, while PSL_SQUARE_CAP (2) results in square caps. Thus, the two last options will
visually lengthen a straight line-segment by half the line width at either end.
long PSL_setlinejoin (struct PSL_CTRL *P, long join)
Changes the current linejoin setting, which handles how lines of finite thickness are joined
together when the meet at different angles. PSL_MITER_JOIN (0) gives a mitered joint
[Default], PSL_ROUND_JOIN (1) makes them round, while PSL_BEVEL_JOIN (2) produces bevel joins.
long PSL_setmiterlimit (struct PSL_CTRL *P, long limit)
Changes the current miter limit used for mitered joins. PSL_MITER_DEFAULT (35) gives
the default PS miter; other values are interpreted as the cutoff acute angle (in degrees) when
mitering becomes active.
long PSL_settransparencymode (struct PSL_CTRL *P, char *mode)
Changes the current PDF transparency rendering mode [Default is Normal]. Choose among
Color, ColorBurn, ColorDodge, Darken, Difference, Exclusion, HardLight, Hue, Lighten,
Luminosity, Multiply, Normal, Overlay, Saturation, SoftLight, and Screen.
long PSL_setdefaults (struct PSL_CTRL *P, double xyscales[], double pagergb[], char *encoding)
Allows changes to the PSL session settings and should be called immediately after
PSL_beginsession. The xyscales array affect an overall magnification of your plot [1,1].
This can be useful if you design a page-sized plot but would then like to magnify (or shrink)
it by a given factor. Change the default paper media color [white; 1/1/1] by specifying an
alternate page color. Passing zero (or NULL for pagergb) will leave the setting unchanged.
Finally, pass the name of the character set encoding (if NULL we select Standard).
long PSL_defunits (struct PSL_CTRL *P, char *name, double value)
Creates a PostScript variable called name and initializes it to the equivalent of value user
units.
long PSL_defpoints (struct PSL_CTRL *P, char *name, double fontsize)
Creates a PostScript variable called name and initializes it to the value that corresponds to
the font size (in points) given by fontsize.
250
1.69. postscriptlight
251
fontsize in points. side can be 0, 1, 2, or 3, which selects lower x-axis, right y-axis, upper
x-axis, or left y-axis, respectively. The label font size is set to 1.5 times the fontsize.
long PSL_plotsymbol (struct PSL_CTRL *P, double x, double y, double size[], long symbol)
Plots a simple geometric symbol centered on plot coordinates (x, y). The argument
symbol selects the geometric symbol to use. Most symbols are scaled to fit inside
a circle of diameter given as size[0], but some symbols take additional parameters.
Choose from these 1-parameter symbols using the predefined self-explanatory integer values PSL_CIRCLE, PSL_DIAMOND, PSL_HEXAGON, PSL_INVTRIANGLE,
PSL_OCTAGON, PSL_PENTAGON, PSL_SQUARE, PSL_STAR, and PSL_TRIANGLE;
these may all be filled and stroked if PSL_setfill has been called first. In addition, you can
choose several line-only symbols that cannot be filled. They are PSL_CROSS, PSL_DOT,
PSL_PLUS, PSL_XDASH, and PSL_YDASH. Finally, more complicated symbols require
more than one parameter to be passed via size. These are PSL_ELLIPSE (size is expected
to contain the three parameter angle, major, and minor axes, which defines an ellipse with
its major axis rotated by angle degrees), PSL_MANGLE (size is expected to contain the
10 parameters radius, angle1, and angle2 for the math angle specification, followed by
tailwidth, headlength, headwidth, shape, status, trim1 and trim2 (see PSL_VECTOR below for explanation), PSL_WEDGE (size is expected to contain the three parameter radius,
angle1, and angle2 for the sector specification), PSL_RECT (size is expected to contain
the two dimensions width and height), PSL_RNDRECT (size is expected to contain the
two dimensions width and height and the radius of the corners), PSL_ROTRECT (size is
expected to contain the three parameter angle, width, and height, with rotation relative to
the horizontal), and PSL_VECTOR (size is expected to contain the 9 parameters x_tip,
y_tip, tailwidth, headlength, headwidth, shape, status, head1, head2, trim1, and trim2. Here
(x_tip,y_tip) are the coordinates to the head of the vector, while (x, y) are those of the tail.
shape can take on values from 0-1 and specifies how far the intersection point between the
base of a straight vector head and the vector line is moved toward the tip. 0.0 gives a triangular head, 1.0 gives an arrow shaped head. The status value is a bit-flag being the sum
of several possible contributions: PSL_VEC_RIGHT (2) = only draw right half of vector
head, PSL_VEC_BEGIN (4) = place vector head at beginning of vector, PSL_VEC_END
(8) = place vector head at end of vector, PSL_VEC_JUST_B (0) = align vector beginning at (x,y), PSL_VEC_JUST_C (16) = align vector center at (x,y), PSL_VEC_JUST_E
(32) = align vector end at (x,y), PSL_VEC_JUST_S (64) = align vector center at (x,y),
PSL_VEC_OUTLINE (128) = draw vector head outline using default pen, PSL_VEC_FILL
(512) = fill vector head using default fill, PSL_VEC_MARC90 (2048) = if angles subtend
90, draw straight angle symbol (PSL_MANGLE only). The symbol may be filled and its
outline stroked depending on the current settings for fill and pen attributes. The parameters
head1 and head2 determines what kind of vector head will be plotted at the two ends (if
selected). 0 = normal vector head, 1 = circle, 2 = terminal crossbar. Finally, trim1 and trim2
adjust the start and end location of the vector.
such that the aspect ratio of the original image is retained. buffer is an unsigned character
array in scanline orientation with 8 pixels per byte. nx, ny refers to the number of pixels
in the image. The rowlength of buffer must be an integral number of 8; pad with zeros.
buffer[0] is upper left corner. You may replace the foreground color (the set bits) with the
f_rgb color and the background color (the unset bits) with b_rgb. Alternatively, pass either
color with the red component set to -1.0 and we will instead issue an image mask that
is see-through for the specified fore- or background component. See the Adobe Systems
PostScript Reference Manual for more details.
long PSL_plotcolorimage (struct PSL_CTRL *P, double x, double y, double xsize, double ysize, int
justify, unsigned char *buffer, long nx, long ny, long depth)
Plots a 1-, 2-, 4-, 8-, or 24-bit deep image at plot coordinates (x, y) justified as per the
argument justify (see JUSTIFICATION for details). The target size of the image is given
by xsize and ysize in user units. If one of these is specified as zero, the corresponding size
is adjusted to the other such that the aspect ratio of the original image is retained. This
functions sets up a call to the PostScript colorimage or image operators. The pixel values
are stored in buffer, an unsigned character array in scanline orientation with gray shade or
r/g/b values (0-255). buffer[0] is the upper left corner. depth is number of bits per pixel (24,
8, 4, 2, or 1). nx, ny refers to the number of pixels in image. The rowlength of buffer must be
an integral number of 8/Idepth. E.g. if depth = 4, then buffer[j]/16 gives shade for pixel[2j1] and buffer[j%16 (mod 16) gives shade for pixel[2j]. When -depth is passed instead then
hardware interpolation of the image is requested (this is implementation dependent). If
-nx is passed with 8- (or 24-) bit images then the first one (or three) bytes of buffer holds the
gray (or r/g/b) color for pixels that are to be masked out using the PS Level 3 Color Mask
method. See the Adobe Systems PostScript Reference Manual for more details.
long PSL_plotepsimage (struct PSL_CTRL *P, double x, double y, double xsize, double ysize, int
justify, unsigned char *buffer, long size, long nx, long ny, long ox, long oy)
Plots an Encapsulated PostScript (EPS) image at plot coordinates (x, y) justified as per the
argument justify (see JUSTIFICATION for details). The target size of the image is given
by xsize and ysize in user units. If one of these is specified as zero, the corresponding size
is adjusted to the other such that the aspect ratio of the original image is retained. The
EPS file is stored in buffer and has size bytes. This function simply includes the image in
the PostScript output stream within an appropriate wrapper. Specify position of lower left
corner and size of image. nx, ny, ox, oy refers to the width, height and origin (lower left
corner) of the BoundingBox in points.
long PSL_loadimage (struct PSL_CTRL *P, FILE *fp, struct imageinfo *header, unsigned char
**image)
Reads the image contents of the EPS file or a raster image pointed to by the open file pointer
fp. The routine can handle Encapsulated PostScript files or 1-, 8-, 24-, or 32-bit raster images
in old, standard, run-length encoded, or RGB-style Sun format. Non-Sun rasters are automatically reformatted to Sun rasters via a system call to GraphicsMagicks or ImageMagicks convert, if installed. The image is returned via the image pointer.
253
long PSL_plottext (struct PSL_CTRL *P, double x, double y, double fontsize, char *text, double
angle, long justify, long mode)
The text is plotted starting at plot coordinates (x, y) and will make an angle with the horizontal. The point (x, y) maps onto different points of the text-string by giving various values
for justify (see JUSTIFICATION for details). If justify is negative, then all leading and
trailing blanks are stripped before plotting. Certain character sequences (flags) have special
meaning to PSL_plottext. @~ toggles between current font and the Mathematical Symbols
font. @%no% selects font no while @%% resets to the previous font. @- turns subscript
on/off, @+ turns superscript on/off, @# turns small caps on/off, and @\ will make a composite character of the following two character. @;r/g/b; changes the font color while @;;
resets it [optionally append =transparency to change the transparency (0100) of the text
(the Default is opaque or 0)], @:size: changes the font size (@:: resets it), and @_ toggles
underline on/off. If text is NULL then we assume PSL_plottextbox was called first. Give
fontsize in points. Normally, the text is typed using solid characters in the current color (set
by PSL_setcolor). To draw outlined characters, set mode == 1; the outline will get the current color and the text is filled with the current fill color (set by PSL_setfill). Use mode ==
2 if the current fill is a pattern. Use mode == 3 to achieve the same as mode == 1, while preventing the outline from obsuring any filled text font; the outline will hence be reduced to
half the selected width. If the text is not filled, mode == 3 operates the same as mode == 1. If
fontsize is negative it means that the current point has already been set before PSL_plottext
was called and that (x, y) should be ignored.
long PSL_plottextbox (struct PSL_CTRL *P, double x, double y, double fontsize, char *text, double
angle, long justify, double offset[], long mode)
This function is used in conjugation with PSL_plottext when a box surrounding the text
string is desired. Taking most of the arguments of PSL_plottext, the user must also specify
mode to indicate whether the box needs rounded (PSL_YES = 1) or straight (PSL_NO = 0)
corners. The box will be colored with the current fill style set by PSL_setfill. That means,
if an outline is desired, and the color of the inside of the box should be set with that routine.
The outline will be drawn with the current pen color (and width). The offset array holds the
horizontal and vertical distance gaps between text and the surrounding text box in distance
units. The smaller of the two determined the radius of the rounded corners (if requested).
long PSL_deftextdim (struct PSL_CTRL *P, char *prefix, double fontsize, char *text)
Computes the dimensions (width and height) required by the selected text given the current font and its fontsize (in points). The values are stored as PostScript variables called
prefix_w and prefix_h, respectively. This function can be used to compute dimensions and,
via BF(PSL_setcommand), calculate chances to position a particular item should be plotted. For instance, if you compute a position this way and wish to plot the text there, pass
the coordinates to PSL_plottext as NaNs. If prefix is BF(-w), BF(-h), BF(-d) or BF(-b), no
PostScript variables will be assigned, but the values of width, height, depth, or both width
and height will be left on the PostScript stack.
long PSL_setparagraph (struct PSL_CTRL *P, double line_space, double par_width, long par_just)
Initialize common settings to be used when typesetting paragraphs of text with
PSL_plotparagraph. Specify the line spacing (1 equals the font size) and paragraph width
(in distance units). Text can be aligned left (PSL_BL), centered (PSL_BC), right (PSL_BR),
or justified (PSL_JUST) and is controlled by par_just.
long PSL_plotparagraphbox (struct PSL_CTRL *P, double x, double y, double fontsize, char *text,
double angle, long justify, double offset[], long mode)
254
Computes and plots the text rectangle for a paragraph using the specified fontsize (in
points). Here, text is an array of the text to be typeset, using the settings initialized by
PSL_setparagraph. The escape sequences described for PSL_plottext can be used to
modify the text. Separate text into several paragraphs by appending \r to the last item in
a paragraph. The whole text block is positioned at plot coordinates x, y, which is mapped
to a point on the block specified by justify (see JUSTIFICATION for details). The whole
block is then shifted by the amounts shift[]. The box will be plotted using the current fill
and outline settings. The offset array holds the horizontal and vertical distance gaps between
text and the surrounding text box in distance units. Use mode to indicate whether the box
should be straight (PSL_RECT_STRAIGHT = 0), rounded (PSL_RECT_ROUNDED = 1),
convex (PSL_RECT_CONVEX = 2) or concave (PSL_RECT_CONCAVE = 3).
long PSL_plotparagraph (struct PSL_CTRL *P, double x, double y, double fontsize, char *text,
double angle, long justify, long mode)
Typesets paragraphs of text using the specified fontsize (in points). Here, text is an array
of the text to be typeset, using the settings initialized by PSL_setparagraph. The escape
sequences described for PSL_plottext can be used to modify the text. Separate text into
several paragraphs by appending \r to the last item in a paragraph. The whole text block is
positioned at plot coordinates x, y, which is mapped to a point on the block specified by
justify (see JUSTIFICATION for details). See PSL_plotparagraphbox for laying down
the surrounding text rectangle first.
long PSL_plottextline (struct PSL_CTRL *P, double *xpath, double *ypath, long *np, long nseg,
void *arg1, void *arg2, char *text[], double angle[], long n_per_seg[], double fontsize, ***long* justify, double offset[], long mode)
Please text along one or more path segments. The function does different things depending on the bit flags in mode. A key distinction occurs if the bit flag contains the bit
PSL_TXT_CURVED (64) which means we wish to typeset the text along a variable and
curved baseline given by the segments in xpath, ypath; otherwise we set straight text (possibly at an angle) and the xpath, ypath are not considered for text placement [If no line drawing is desired then these two arrays may be NULL]. We will describe the action taken for
each bit value. Multiple values may be passed at the same time and we processes from low to
hight bit. PSL_TXT_INIT: When mode contains this bit (1) we will initialize all the required
variables and store them in the PostScript file. PSL_TXT_SHOW: We wish to see the text
strings (otherwise they may only serve as guides to set up clip paths). PSL_TXT_CLIP_ON:
Use the text and the paths to set up clip paths. PSL_TXT_DRAW: Draw the lines defined by
the xpath, ypath arrays. PSL_TXT_CLIP_OFF: Turn the text path clipping off. We pass the
text strings via text. The locations of text plotting depends on whether PSL_TXT_CURVED
is selected. If it is then you must pass as arg1 the node array indicating at which node in
the xpath, ypath array the text will be plotted; let arg2 be NULL. For straight baselines you
must instead pass another set of x,y coordinates with the locations of the text label placements via arg1, arg2. Each label has its own entry in the angle array. The text is an array
of text pointers to the individual text items. The offset array holds the x and y distance gaps
between text and the surrounding text box in user units (the clip path is the combination
of all these text boxes). Use justify to specify how the text string relates to the coordinates
(see BF(JUSTIFICATION) for details). PSL_TXT_FILLBOX (128) will fill the text box
(this requires you to first define the text box rgb color with PSL_define_rgb by setting
a local PostScript variable that must be called PSL_setboxrgb). PSL_TXT_DRAWBOX
(256) will draw the text box outlines (this requires you to first define the text box pen with
PSL_define_pen by setting a local PostScript variable that must be called PSL_setboxpen).
Before calling this function you must also initialize a PSL array for line pens and text fonts.
1.69. postscriptlight
255
1.69.12 Clipping
Here are functions used to activate and deactivate clipping regions.
long PSL_beginclipping (struct PSL_CTRL *P, double x, double y, long n, double rgb[], long flag)
Sets up a user-definable clip path as a series on n points with plot coordinates (x, y). Plotting
outside this polygon will be clipped until PSL_endclipping is called. If rgb[0] = -1 the
inside of the path is left empty, otherwise it is filled with the specified color. flag is used to
create complex clip paths consisting of several disconnected regions, and takes on values
0-3. flag = PSL_PEN_MOVE_ABS (1) means this is the first path in a multisegment clip
path. flag = PSL_PEN_DRAW_ABS (2) means this is the last segment. Thus, for a single
path, flag = PSL_PEN_DRAW_AND_STROKE_ABS (3).
long PSL_endclipping (struct PSL_CTRL *P, long mode)
Depending on the mode it restores the clip path. The mode values can be: n will restore n levels of text-based clipping, n will restore n levels of polygon clipping, PSL_ALL_CLIP_TXT will undo all levels of text-based clipping, and
PSL_ALL_CLIP_POL will undo all levels of polygon-based clipping.
1.69.14 Authors
Paul Wessel, School of Ocean and Earth Science and Technology, http://www.soest.hawaii.edu.
Remko Scharroo, EUMETSAT, Darmstadt, Germany, http://www.eumetsat.int.
1.69.15 Bugs
Caveat Emptor: The authors are not responsible for any disasters, suicide attempts, or ulcers caused by
correct or incorrect use of PSL. If you find bugs, please report them to the authors by electronic mail.
Be sure to provide enough detail so that we can recreate the problem.
1.69.16 References
Adobe Systems Inc., 1990, PostScript language reference manual, 2nd edition, Addison-Wesley, (ISBN
0-201-18127-4).
256
1.70 psmask
psmask - Clip or mask map areas with no data table coverage
1.70.1 Synopsis
psmask [ table ] -Iincrement -Jparameters -Rregion [ -B[p|s]parameters ] [ -Ddumpfile ] [ -F[l|r] ] [
-Gfill ] [ -Jz|Zparameters ] [ -K ] [ -L[+|-]nodegrid ] [ -N ] [ -O ] [ -P ] [ -Qcut ] [ -Ssearch_radius[unit]
] [ -T ] [ -U[stamp] ] [ -V[level] ] [ -Xx_offset ] [ -Yy_offset ] [ -bibinary ] [ -ccopies ] [ -dinodata ] [
-hheaders ] [ -iflags ] [ -pflags ] [ -r ] [ -ttransp ] [ -:[i|o] ]
psmask -C [ -K ] [ -O ]
Note: No space is allowed between the option flag and the associated arguments.
1.70.2 Description
psmask reads a (x,y,z) file [or standard input] and uses this information to find out which grid cells are
reliable. Only grid cells which have one or more data points are considered reliable. As an option, you
may specify a radius of influence. Then, all grid cells that are within radius of a data point are considered
reliable. Furthermore, an option is provided to reverse the sense of the test. Having found the reliable/not
reliable points, psmask will either paint tiles to mask these nodes (with the -T switch), or use contouring
to create polygons that will clip out regions of no interest. When clipping is initiated, it will stay in effect
until turned off by a second call to psmask using the -C option.
1.70.3 Required
-Ixinc[unit][=|+][/yinc[unit][=|+]] x_inc [and optionally y_inc] is the grid spacing. Optionally, append
a suffix modifier. Geographical (degrees) coordinates: Append m to indicate arc minutes or s
to indicate arc seconds. If one of the units e, f, k, M, n or u is appended instead, the increment
is assumed to be given in meter, foot, km, Mile, nautical mile or US survey foot, respectively,
and will be converted to the equivalent degrees longitude at the middle latitude of the region (the
conversion depends on PROJ_ELLIPSOID). If y_inc is given but set to 0 it will be reset equal to
x_inc; otherwise it will be converted to degrees latitude. All coordinates: If = is appended then the
corresponding max x (east) or y (north) may be slightly adjusted to fit exactly the given increment
[by default the increment may be adjusted slightly to fit the given domain]. Finally, instead of
giving an increment you may specify the number of nodes desired by appending + to the supplied
integer argument; the increment is then recalculated from the number of nodes and the domain.
The resulting increment value depends on whether you have selected a gridline-registered or pixelregistered grid; see App-file-formats for details. Note: if -Rgrdfile is used then the grid spacing
has already been initialized; use -I to override the values.
-Jparameters (more ...) Select map projection. [Not mandatory when -D].
-R[unit]xmin/xmax/ymin/ymax[r] (more ...) Specify the region of interest.
For perspective view p, optionally append /zmin/zmax. (more ...)
1.70. psmask
257
258
1.70.5 Units
For map distance unit, append unit d for arc degree, m for arc minute, and s for arc second, or e for
meter [Default], f for foot, k for km, M for statute mile, n for nautical mile, and u for US survey foot.
By default we compute such distances using a spherical approximation with great circles. Prepend - to
a distance (or the unit is no distance is given) to perform Flat Earth calculations (quicker but less
accurate) or prepend + to perform exact geodesic calculations (slower but more accurate).
1.70.6 Examples
To make an overlay PostScript file that will mask out the regions of a contour map where there is no
control data using clip polygons, use:
gmt psmask africa_grav.xyg -R20/40/20/40 -I5m -JM10i -O -K > mask.ps
We do it again, but this time we wish to save the clipping polygons to file all_pols.txt:
gmt psmask africa_grav.xyg -R20/40/20/40 -I5m -Dall_pols.txt
A repeat of the first example but this time we use white tiling:
gmt psmask africa_grav.xyg -R20/40/20/40 -I5m -JM10i -T -O -K -Gwhite > mask.ps
1.71 psrose
psrose - Plot a polar histogram (rose, sector, windrose diagrams)
1.71. psrose
259
1.71.1 Synopsis
psrose [ table ] [ -A[r]sector_width ] [ -B[p|s]parameters ] [ -Cm|mode_file ] [ -D ] [ -Gfill ] [ -I
] [ -K ] [ -L[wlabel/elabel/slabel/nlabel] ] [ -Mparameters ] [ -O ] [ -P ] [ -Rr0/r1/az_0/az_1 ] [ S[n]*radial_scale* ] [ -T ] [ -U[stamp] ] [ -V[level] ] [ -W[v]pen ] [ -Xx_offset ] [ -Yy_offset ] [ -Zu|scale
] [ -bibinary ] [ -ccopies ] [ -dinodata ] [ -hheaders ] [ -iflags ] [ -pflags ] [ -ttransp ] [ -:[i|o] ]
Note: No space is allowed between the option flag and the associated arguments.
1.71.2 Description
psrose reads (length,azimuth) pairs from file [or standard input] and generates PostScript code that will
plot a windrose diagram. Optionally (with -A), polar histograms may be drawn (sector diagram or rose
diagram). Options include full circle and half circle plots. The PostScript code is written to standard
output. The outline of the windrose is drawn with the same color as MAP_DEFAULT_PEN.
-Cm|mode_file Plot vectors showing the principal directions given in the mode_file file. Alternatively,
specify -Cm to compute and plot mean direction. See -M to control the vector attributes.
-D Shift sectors so that they are centered on the bin interval (e.g., first sector is centered on 0 degrees).
-F Do not draw the scale length bar [Default plots scale in lower right corner]
-Gfill Selects shade, color or pattern for filling the sectors [Default is no fill]K.
-I Inquire. Computes statistics needed to specify useful -R. No plot is generated.
-K (more ...) Do not finalize the PostScript plot.
-L[wlabel/elabel/slabel/nlabel] Specify labels for the 0, 90, 180, and 270 degree marks. For full-circle
plot the default is WEST/EAST/SOUTH/NORTH and for half-circle the default is 90W/90E/-/0.
A - in any entry disables that label. Use -L with no argument to disable all four labels
260
-Mparameters Used with -C to modify vector parameters. For vector heads, append vector head size
[Default is 0, i.e., a line]. See VECTOR ATTRIBUTES for specifying additional attributes. If -C
is not given and the current plot mode is to draw a windrose diagram then using -M will add vector
heads to all individual directions using the supplied attributes.
-O (more ...) Append to existing PostScript plot.
-P (more ...) Select Portrait plot orientation.
-Rr0/r1/az_0/az_1 Specifies the region of interest in (r,azimuth) space. r0 is 0, r1 is max length in
units. For azimuth, specify either -90/90 or 0/180 for half circle plot or 0/360 for full circle.
-S[n]*radial_scale* Specifies radius of circle. Use -Sn to normalize input radii to go from 0 to 1.
-T Specifies that the input data is orientation data (has a 180 degree ambiguity) instead of true 0-360
degree directions [Default].
-U[just/dx/dy/][c|label] (more ...) Draw GMT time stamp logo on plot.
-V[level] (more ...) Select verbosity level [c].
-Wpen Set pen attributes for sector outline or rose plot. [Default is no outline]. Use -Wvpen to change
pen used to draw vector (requires -C) [Default is same as sector outline].
-X[a|c|f|r][x-shift[u]]
-Y[a|c|f|r][y-shift[u]] (more ...) Shift plot origin.
-Zscale Multiply the data radii by scale. E.g., use -Z0.001 to convert your data from m to km. To exclude
the radii from consideration, set them all to unity with -Zu [Default is no scaling].
-: Input file has (azimuth,radius) pairs rather than the expected (radius,azimuth).
-bi[ncols][t] (more ...) Select native binary input. [Default is 2 input columns].
-ccopies (more ...) Specify number of plot copies [Default is 1].
-dinodata (more ...) Replace input columns that equal nodata with NaN.
-h[i|o][n][+c][+d][+rremark][+rtitle] (more ...) Skip or produce header record(s).
-icols[l][sscale][ooffset][,...] (more ...) Select input columns (0 is first column).
-p[x|y|z]azim/elev[/zlevel][+wlon0/lat0[/z0]][+vx0/y0] (more ...) Select perspective view.
-t[transp] (more ...) Set PDF transparency level in percent.
-^ or just - Print a short message about the syntax of the command, then exits (NOTE: on Windows use
just -).
-+ or just + Print an extensive usage (help) message, including the explanation of any module-specific
option (but not the GMT common options), then exits.
-? or no arguments Print a complete usage (help) message, including the explanation of options, then
exits.
1.71. psrose
261
1.71.6 Examples
To plot a half circle rose diagram of the data in the file fault_segments.az_r (containing pairs of (azimuth,
length in meters), using a 10 degree bin sector width, on a circle of radius = 3 inch, grid going out to
radius = 150 km in steps of 25 km with a 30 degree sector interval, radial direction annotated every 50
km, using a light blue shading outlined by a solid red pen (width = 0.75 points), draw the mean azimuth,
and shown in Portrait orientation, use:
262
To plot a full circle wind rose diagram of the data in the file lines.r_az, on a circle of radius = 5 cm,
grid going out to radius = 500 units in steps of 100 with a 45 degree sector interval, using a solid pen
(width = 0.5 point, and shown in landscape [Default] orientation with UNIX timestamp and command
line plotted, use:
gmt psrose lines.az_r -R0/500/0/360 -S5c -Bxg100 -Byg45 -B+t"Windrose diagram" W0.5p -Uc | lpr
Redo the same plot but this time add orange vector heads to each direction (with nominal head size 0.5
cm but this will be reduced linearly for lengths less than 1 cm) and save the plot, use:
gmt psrose lines.az_r -R0/500/0/360 -S5c -Bxg100 -Byg45 -B+t"Windrose diagram" M0.5c+e+gorange+n1c -W0.5p -Uc > rose.ps
1.71.7 Bugs
No default radial scale and grid settings for polar histograms. User must run psrose -I to find max length
in binned data set.
1.72 psscale
psscale - Plot a gray or color scale-bar on maps
1.72.1 Synopsis
psscale -Drefpoint [ -B[p|s]parameters ] [ -Ccpt ] [ -Fbox ] [ -Gzlo/zhi ] [ -I[max_intens|low_i/high_i]
] [ -Jparameters ] [ -Jz|Zparameters ] [ -K ] [ -L[i][gap] ] [ -M ] [ -N[p|dpi ]] [ -O ] [ -P ] [ -Q ] [
-Rregion ] [ -S ] [ -U[stamp] ] [ -V[level] ] [ -Wscale ] [ -Xx_offset ] [ -Yy_offset ] [ -Zzfile ] [ -ccopies
] [ -pflags ] [ -ttransp ]
Note: No space is allowed between the option flag and the associated arguments.
1.72.2 Description
psscale plots gray scales or color scales on maps. Both horizontal and vertical scales are supported. For
CPTs with gradational colors (i.e., the lower and upper boundary of an interval have different colors)
psscale will interpolate to give a continuous scale. Variations in intensity due to shading/illumination
may be displayed by setting the option -I. Colors may be spaced according to a linear scale, all be equal
size, or by providing a file with individual tile widths. The font used for the annotations along the scale
and optional units is specified by FONT_ANNOT_PRIMARY. If a label is requested, it is plotted with
FONT_LABEL.
1.72. psscale
263
another value. Finally, append +s to draw an offset background shaded region. Here, dx/dy
indicates the shift relative to the foreground frame [4p/-4p] and shade sets the fill style to use for
shading [gray50].
-Gzlo/zhi Truncate the incoming CPT so that the lowest and highest z-levels are to zlo and zhi. If one of
these equal NaN then we leave that end of the CPT alone. The truncation takes place before the
plotting.
-I[max_intens|low_i/high_i] Add illumination effects. Optionally, set the range of intensities from - to
+ max_intens. If not specified, 1 is used. Alternatively, append low/high intensities to specify an
asymmetric range [Default is no illumination].
-Jparameters (more ...) Select map projection.
-Jz|Zparameters (more ...) Set z-axis scaling; same syntax as -Jx.
-K (more ...) Do not finalize the PostScript plot.
-L[i][gap] Gives equal-sized color rectangles. Default scales rectangles according to the z-range in the
CPT (Also see -Z). If set, any equal interval annotation set with -B will be ignored. If gap is
appended and the CPT is discrete we will center each annotation on each rectangle, using the
lower boundary z-value for the annotation. If i is prepended we annotate the interval range instead.
If -I is used then each rectangle will have its constant color modified by the specified intensity.
-M Force a monochrome graybar using the (television) YIQ transformation.
-N[p|dpi] Controls how the color scale is represented by the PostScript language. To preferentially draw
color rectangles (e.g., for discrete colors), append p. Otherwise we will preferentially draw images
(e.g., for continuous colors). Optionally append effective dots-per-inch for rasterization of color
scales [600].
-O (more ...) Append to existing PostScript plot.
-P (more ...) Select Portrait plot orientation.
-Q Select logarithmic scale and power of ten annotations. All z-values in the CPT will be converted to
p = log10(z) and only integer p values will be annotated using the 10^p format [Default is linear
scale].
-R[unit]west/east/south/north[/zmin/zmax][r] west, east, south, and north specify the region of interest, 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 w/e/s/n. The two
shorthands -Rg and -Rd stand for global domain (0/360 and -180/+180 in longitude respectively,
with -90/+90 in latitude). Alternatively for grid creation, give Rcodelon/lat/nx/ny, where code is
a 2-character combination of L, C, R (for left, center, or right) and T, M, B for top, middle, or
bottom. e.g., BL for lower left. This indicates which point on a rectangular region the lon/lat coordinate refers to, and the grid dimensions nx and ny with grid spacings via -I is used to create
the corresponding region. Alternatively, specify the name of an existing grid file and the -R settings (and grid spacing, if applicable) are copied from the grid. Using -Runit expects projected
(Cartesian) coordinates compatible with chosen -J and we inversely project to determine actual
rectangular geographic region. For perspective view (-p), optionally append /zmin/zmax. In case
of perspective view (-p), a z-range (zmin, zmax) can be appended to indicate the third dimension.
This needs to be done only when using the -Jz option, not when using only the -p option. In the
latter case a perspective view of the plane is plotted, with no third dimension.
For perspective view p, optionally append /zmin/zmax. (more ...)
-S Do not separate different color intervals with black grid lines.
1.72. psscale
265
1.72.5 Examples
To plot a a horizontal color scale (12 cm long; 0.5 cm wide) at the reference point (8,1) (paper coordinates) with justification at top center and automatic annotation interval, do
gmt makecpt -T-200/1000/100 -Crainbow > t.cpt
gmt psscale -Ct.cpt -Dx8c/1c+w12c/0.5c+jTC+h -Bxaf+l"topography" -By+lkm > map.ps
To append a vertical color scale (7.5 cm long; 1.25 cm wide) to the right of a plot that is 6 inch wide and
4 inch high, using illumination, and show back- and foreground colors, and annotating every 5 units, we
provide the reference point and select the left-mid anchor point via
gmt psscale -Dx6.5i+jLM/2i+w7.5c/1.25c+e -O -Ccolors.cpt -I -Bx5+lBATHYMETRY By+lm >> map.ps
To overlay a horizontal color scale (4 inches long; 1 cm wide) above a Mercator map produced by a
previous call, ensuring a 2 cm offset from the map frame, use
gmt psscale -DjCT+w4i/1c+o0/2c+h -O -Ccolors.cpt -Baf -R -J >> map.ps
1.72.6 Notes
When the CPT is discrete and no illumination is specified, the color bar will be painted using polygons.
For all other cases we must paint with an image. Some color printers may give slightly different colors
for the two methods given identical RGB values.
266
1.73 pstext
pstext - Plot or typeset text on maps
1.73.1 Synopsis
pstext [ textfiles ] -Jparameters -Rwest/east/south/north[/zmin/zmax][r] [ -A ] -B[p|s]parameters
[ -D[j|J]dx[/dy][v[pen]] ] [ -F[+a[angle]][+c[justify]][+f[font]][+j[justify]][+h|+l |+l |+r[first]
|+ttext|z[format]] ] [ -Gcolor ] [ -Jparameters ] [ -K ] [ -L ] [ -M ] [ -N ] [ -O ] [ -P ] [ -Ql|u ]
[ -To|O|c|C ] [ [ -Wpen ] [ -Xx_offset ] [ -Yy_offset ] [ -U[stamp] ] [ -Z ] [ -acol=name[...] ] [ -ccopies ]
[ -fflags ] [ -hheaders ] [ -iflags ] [ -pflags ] [ -ttransp ] [ -oflags ] [ -:[i|o] ]
Note: No space is allowed between the option flag and the associated arguments.
1.73.2 Description
pstext plots text strings of variable size, font type, and orientation. Various map projections are provided, with the option to draw and annotate the map boundaries. PostScript code is written to standard
output. Greek characters, subscript, superscript, and small caps are supported as follows: The sequence
@~ toggles between the selected font and Greek (Symbol). @%no% sets the font to no; @%% resets the font to the starting font, @- toggles subscripts on/off, @+ toggles superscript on/off, @# toggles small caps on/off, @;color; changes the font color (@;; resets it), @:size: changes the font size
(@:: resets it), and @_ toggles underline on/off. @@ prints the @ sign. @e, @o, @a, @E, @O, @A
give the accented Scandinavian characters. Composite characters (overstrike) may be indicated with the
@!<char1><char2> sequence, which will print the two characters on top of each other. To learn the octal
codes for symbols not available on the keyboard and some accented European characters, see Section
Char-esc-seq and Appendix Chart-Octal-Codes-for-Chars in the GMT Technical Reference and Cookbook. Note that PS_CHAR_ENCODING must be set to an extended character set in your gmt.conf file
in order to use the accented characters. Using the -G or -W options, a rectangle underlying the text may
be plotted (does not work for strings with sub/super scripts, symbols, or composite characters, except in
paragraph mode (-M)).
267
points, font is the font to use, and color sets the font color. To draw outline fonts you append =pen
to the font specification. The angle is measured in degrees counter-clockwise from horizontal, and
justify sets the alignment. If font is not an integer, then it is taken to be a text string with the desired
font name (see -L for available fonts). The alignment refers to the part of the text string that will
be mapped onto the (x,y) point. Choose a 2 character combination of L, C, R (for left, center, or
right) and T, M, B for top, middle, or bottom. e.g., BL for lower left.
-A Angles are given as azimuths; convert them to directions using the current projection.
-B[p|s]parameters (more ...) Set map boundary intervals.
-Cdx/dy Sets the clearance between the text and the surrounding box [15%]. Only used if -W or
-G are specified. Append the unit you want (cm, inch, or point; if not given we consult
PROJ_LENGTH_UNIT) or % for a percentage of the font size.
-D[j|J]dx[/dy][v[pen]] Offsets the text from the projected (x,y) point by dx,dy [0/0]. If dy is not specified
then it is set equal to dx. Use -Dj to offset the text away from the point instead (i.e., the text
justification will determine the direction of the shift). Using -DJ will shorten diagonal offsets at
corners by sqrt(2). Optionally, append v which will draw a line from the original point to the
shifted point; append a pen to change the attributes for this line.
-F[+a|A[angle]][+c[justify]][+f[font]][+j[justify]][+h|+l |+l |+r[first] |+ttext|z[format]] By
default, text will be placed horizontally, using the primary annotation font attributes
(FONT_ANNOT_PRIMARY), and centered on the data point. Use this option to override
these defaults by specifying up to three text attributes (font, angle, and justification) directly on
the command line. Use +f to set the font (size,fontname,color); if no font info is given then the
input file must have this information in one of its columns. Use +a to set the angle; if no angle is
given then the input file must have this as a column. Alternatively, use +A to force text-baselines
to convert into the -90/+90 range. Use +j to set the justification; if no justification is given then
the input file must have this as a column. Items read from the data file should be in the same
order as specified with the -F option. Example: -F+f12p,Helvetica-Bold,red+j+a selects a 12p
red Helvetica-Bold font and expects to read the justification and angle from the file, in that order,
after x, y and before text. In addition, the +c justification lets us use x,y coordinates extracted from
the -R string instead of providing them in the input file. For example -F+cTL gets the x_min,
y_max from the -R string and plots the text at the Upper Left corner of the map. Normally, the
text to be plotted comes from the data record. Instead, use +h or +l to select the text as the most
recent segment header or segment label, respectively in a multisegment input file, +r to use the
record number (counting up from first), +ttext to set a fixed text string, or zto format incoming z
values to a string using the supplied format [use FORMAT_FLOAT_MAP].
-Gcolor Sets the shade or color used for filling the text box [Default is no fill]. Alternatively, use -Gc
to plot the text and then use the text dimensions (and -C) to build clip paths and turn clipping on.
This clipping can then be turned off later with psclip -C. To not plot the text but activate clipping,
use -GC instead.
-Jz|Zparameters (more ...) Set z-axis scaling; same syntax as -Jx.
-K (more ...) Do not finalize the PostScript plot.
-L Lists the font-numbers and font-names available, then exits.
-M Paragraph mode. Files must be multiple segment files. Segments are separated by a special record
whose first character must be flag [Default is >]. Starting in the 3rd column, we expect to find
information pertaining to the typesetting of a text paragraph (the remaining lines until next segment header). The information expected is (x y [font angle justify] linespace parwidth parjust),
where x y font angle justify are defined above (font, angle, and justify can be set via -F), while
268
linespace and parwidth are the linespacing and paragraph width, respectively. The justification of
the text paragraph is governed by parjust which may be l(eft), c(enter), r(ight), or j(ustified). The
segment header is followed by one or more lines with paragraph text. Text may contain the escape
sequences discussed above. Separate paragraphs with a blank line. Note that here, the justification
set via -F+j applies to the box alignment since the text justification is set by parjust.
-N Do NOT clip text at map boundaries [Default will clip].
-O (more ...) Append to existing PostScript plot.
-P (more ...) Select Portrait plot orientation.
-Q Change all text to either lower or upper case [Default leaves all text as is].
-T Specify the shape of the textbox when using -G and/or -W. Choose lower case o to get a straight
rectangle [Default]. Choose upper case O to get a rounded rectangle. In paragraph mode (-M) you
can also choose lower case c to get a concave rectangle or upper case C to get a convex rectangle.
-U[just/dx/dy/][c|label] (more ...) Draw GMT time stamp logo on plot.
-V[level] (more ...) Select verbosity level [c].
-Wpen Sets the pen used to draw a rectangle around the text string (see -T) [Default is width = default,
color = black, style = solid].
-X[a|c|f|r][x-shift[u]]
-Y[a|c|f|r][y-shift[u]] (more ...) Shift plot origin.
-Z For 3-D projections: expect each item to have its own level given in the 3rd column, and -N is
implicitly set. (Not implemented for paragraph mode).
-acol=name[...] (more ...) Set aspatial column associations col=name.
-ccopies (more ...) Specify number of plot copies [Default is 1].
-f[i|o]colinfo (more ...) Specify data types of input and/or output columns.
-h[i|o][n][+c][+d][+rremark][+rtitle] (more ...) Skip or produce header record(s).
-:[i|o] (more ...) Swap 1st and 2nd column on input and/or output.
-p[x|y|z]azim/elev[/zlevel][+wlon0/lat0[/z0]][+vx0/y0] (more ...) Select perspective view. (Not implemented for paragraph mode).
-t[transp] (more ...) Set PDF transparency level in percent.
-^ or just - Print a short message about the syntax of the command, then exits (NOTE: on Windows use
just -).
-+ or just + Print an extensive usage (help) message, including the explanation of any module-specific
option (but not the GMT common options), then exits.
-? or no arguments Print a complete usage (help) message, including the explanation of options, then
exits.
1.73.5 Examples
To plot just the red outlines of the (lon lat text strings) stored in the file text.d on a Mercator plot with
the given specifications, use
1.73. pstext
269
1.73.7 Limitations
In paragraph mode, the presence of composite characters and other escape sequences may lead to unfortunate word splitting. Also, if a font is requested with an outline pen it will not be used in paragraph
mode. Note if any single word is wider than your chosen paragraph width then the paragraph width is
automatically enlarged to fit the widest word.
1.74 pswiggle
pswiggle - Plot z = f(x,y) anomalies along tracks
1.74.1 Synopsis
pswiggle [ table ] -Jparameters -Rwest/east/south/north[/zmin/zmax][r] -Zscale [ -Aazimuth ]
[ -B[p|s]parameters ] [ -Ccenter ] [ -G[+|-|=]fill ] [ -Ifix_az ] [ -K ] [ -O ] [ -P ] [ S[x]lon0/lat0/length[/units] ] [ -Tpen ] [ -U[stamp] ] [ -V[level] ] [ -Wpen ] [ -Xx_offset ] [ -Yy_offset ]
[ -bibinary ] [ -ccopies ] [ -dinodata ] [ -fflags ] [ -ggaps ] [ -hheaders ] [ -iflags ] [ -pflags ] [ -ttransp ]
[ -:[i|o] ]
Note: No space is allowed between the option flag and the associated arguments.
270
1.74.2 Description
pswiggle reads (x,y,z) triplets from files [or standard input] and plots z as a function of distance along
track. This means that two consecutive (x,y) points define the local distance axis, and the local z axis
is then perpendicular to the distance axis. The user may set a preferred positive anomaly plot direction,
and if the positive normal is outside the plus/minus 90 degree window around the preferred direction,
then 180 degrees are added to the direction. Either the positive or the negative wiggle may be shaded.
The resulting PostScript code is written to standard output.
1.74. pswiggle
271
1.74.5 Examples
To plot the magnetic anomaly stored in the file track.xym along track @ 1000 nTesla/cm (after removing
a mean value of 32000 nTesla), using a 15-cm-wide Polar Stereographic map ticked every 5 degrees in
Portrait mode, with positive anomalies in red on a blue track of width 0.25 points, use
gmt pswiggle track.xym -R-20/10/-80/-60 -JS0/90/15c -Z1000 -B5 \
-C32000 -P -Gred -T0.25p,blue -S1000 -V > track_xym.ps
1.74.6 Bugs
Sometimes the (x,y) coordinates are not printed with enough significant digits, so the local perpendicular
to the track swings around a lot. To see if this is the problem, you should do this:
awk '{ if (NR > 1) print atan2(y-$1, x-$2); y=$1; x=$2; }' yourdata.xyz | more
(note that output is in radians; on some machines you need nawk to do this). Then if these numbers
jump around a lot, you may do this:
awk '{ print NR, $0 }' yourdata.xyz | filter1d -Fb5 -N4/0 \
--FORMAT_FLOAT_OUT=%.12g > smoothed.xyz
272
1.75 psxy
psxy - Plot lines, polygons, and symbols on maps
1.75.1 Synopsis
psxy [ table ] -Jparameters -Rwest/east/south/north[/zmin/zmax][r] [ -A[m|p|x|y] ] [ -B[p|s]parameters
] [ -Ccpt ] [ -Ddx/dy ] [ -E[x[+]|y[+]|X|Y][n][cap][/[-|+]pen] ] [ -F[c|n|r][refpoint] ] [ -Gfill ] [ Iintens ] [ -Jparameters ] [ -K ] [ -L[+b|d|D][+xl|r|x0][+yl|r|y0][+ppen] ] [ -N[c|r] ] [ -O ] [ -P ] [
-S[symbol][size[u] ] [ -T ] [ -U[stamp] ] [ -V[level] ] [ -W[pen][attr] ] [ -Xx_offset ] [ -Yy_offset ] [
-aflags ] [ -bibinary ] [ -ccopies ] [ -dinodata ] [ -fflags ] [ -ggaps ] [ -hheaders ] [ -iflags ] [ -pflags ] [
-ttransp ] [ -:[i|o] ]
Note: No space is allowed between the option flag and the associated arguments.
1.75.2 Description
psxy reads (x,y) pairs from files [or standard input] and generates PostScript code that will plot lines,
polygons, or symbols at those locations on a map. If a symbol is selected and no symbol size given, then
psxy will interpret the third column of the input data as symbol size. Symbols whose size is <= 0 are
skipped. If no symbols are specified then the symbol code (see -S below) must be present as last column
in the input. If -S is not used, a line connecting the data points will be drawn instead. To explicitly close
polygons, use -L. Select a fill with -G. If -G is set, -W will control whether the polygon outline is drawn
or not. If a symbol is selected, -G and -W determines the fill and outline/no outline, respectively. The
PostScript code is written to standard output.
1.75. psxy
273
third column. Additional fields are shifted over by one column (optional size would be 4th rather
than 3rd field, etc.). If -S is not set, then psxy expects the user to supply a multisegment file where
each segment header contains a -Zval string. The val will control the color of the line or polygon
(if -L is set) via the CPT.
-Ddx/dy Offset the plot symbol or line locations by the given amounts dx/dy [Default is no offset]. If dy
is not given it is set equal to dx.
-E[x[+]|y[+]|X|Y][n][cap][/[-|+]pen] Draw symmetrical error bars. Append x and/or y to indicate which
bars you want to draw (Default is both x and y). The x and/or y errors must be stored in the
columns after the (x,y) pair [or (x,y,size) triplet]. If a + is appended after x and/or y then we
will draw asymmetrical error bar; these requires two rather than one extra data column. The cap
parameter indicates the length of the end-cap on the error bars [7p]. Pen attributes for error bars
may also be set [Defaults: width = default, color = black, style = solid]. A leading + will use the
lookup color (via -C) for both symbol fill and error pen color, while a leading - will set error pen
color and turn off symbol fill. If upper case X and/or Y is used we will instead draw box-andwhisker (or stem-and-leaf) symbols. The x (or y) coordinate is then taken as the median value,
and 4 more columns are expected to contain the minimum (0% quantile), the 25% quantile, the
75% quantile, and the maximum (100% quantile) values. The 25-75% box may be filled by using
-G. If n is appended to X (or Y) we draw a notched box-and-whisker symbol where the notch
width reflects the uncertainty in the median. Then a 5th extra data column is expected to contain
the number of points in the distribution.
-F[c|n|r][a|f|s|r|refpoint] Alter the way points are connected (by specifying a scheme) and data are
grouped (by specifying a method). Append one of three line connection schemes: c: Draw continuous line segments for each group [Default]. r: Draw line segments from a reference point reset
for each group. n: Draw networks of line segments between all points in each group. Optionally,
append the one of four segmentation methods to define the group: a: Ignore all segment headers,
i.e., let all points belong to a single group, and set group reference point to the very first point
of the first file. f: Consider all data in each file to be a single separate group and reset the group
reference point to the first point of each group. s: Segment headers are honored so each segment
is a group; the group reference point is reset to the first point of each incoming segment [Default].
r: Same as s, but the group reference point is reset after each record to the previous point (this
method is only available with the -Fr scheme). Instead of the codes a|f|s|r you may append the
coordinates of a refpoint which will serve as a fixed external reference point for all groups.
-Gfill Select color or pattern for filling of symbols or polygons [Default is no fill]. Note that psxy will
search for -G and -W strings in all the segment headers and let any values thus found over-ride
the command line settings.
-Iintens Use the supplied intens value (nominally in the -1 to + 1 range) to modulate the fill color by
simulating illumination [none].
-Jz|Zparameters (more ...) Set z-axis scaling; same syntax as -Jx.
-K (more ...) Do not finalize the PostScript plot.
-L[+b|d|D][+xl|r|x0][+yl|r|y0][+ppen] Force closed polygons. Alternatively, append modifiers to build
a polygon from a line segment. Append +d to build symmetrical envelope around y(x) using
deviations dy(x) given in extra column 3. Append +D to build asymmetrical envelope around y(x)
using deviations dy1(x) and dy2(x) from extra columns 3-4. Append +b to build asymmetrical
envelope around y(x) using bounds yl(x) and yh(x) from extra columns 3-4. Append +xl|r|x0 to
connect first and last point to anchor points at either xmin, xmax, or x0, or append +yb|t|y0 to
connect first and last point to anchor points at either ymin, ymax, or y0. Polygon may be painted
(-G) and optionally outlined by adding +ppen [no outline].
274
-N[c|r] Do NOT clip symbols that fall outside map border [Default plots points whose coordinates
are strictly inside the map border only]. The option does not apply to lines and polygons which
are always clipped to the map region. For periodic (360-longitude) maps we must plot all symbols
twice in case they are clipped by the repeating boundary. The -N will turn off clipping and not plot
repeating symbols. Use -Nr to turn off clipping but retain the plotting of such repeating symbols,
or use -Nc to retain clipping but turn off plotting of repeating symbols.
-O (more ...) Append to existing PostScript plot.
-P (more ...) Select Portrait plot orientation.
-S[symbol][size[u]] Plot symbols. If present, size is symbol size in the unit set in gmt.conf (unless c, i,
or p is appended). If the symbol code (see below) is not given it will be read from the last column
in the input data; this cannot be used in conjunction with binary input. Optionally, append c, i, or p
to indicate that the size information in the input data is in units of cm, inch, or point, respectively
[Default is PROJ_LENGTH_UNIT]. Note: if you provide both size and symbol via the input file
you must use PROJ_LENGTH_UNIT to indicate the unit used for the symbol size or append the
units to the sizes in the file. If symbol sizes are expected via the third data column then you may
convert those values to suitable symbol sizes via the -i mechanism.
The uppercase symbols A, C, D, G, H, I, N, S, T are normalized to have the same area as a circle
with diameter size, while the size of the corresponding lowercase symbols refers to the diameter
of a circumscribed circle.
You can change symbols by adding the required -S option to any of your multisegment headers.
Choose between these symbol codes:
-S- x-dash (-). size is the length of a short horizontal (x-dir) line segment.
-S+ plus (+). size is diameter of circumscribing circle.
-Sa star. size is diameter of circumscribing circle.
-Sb[size[c|i|p|u]][b[base]] Vertical bar extending from base to y. size is bar width. Append u if
size is in x-units [Default is plot-distance units]. By default, base = ymin. Append b[base]
to change this value. If base is not appended then we read it from the last input data column.
-SB[size[c|i|p|u]][b[base]] Horizontal bar extending from base to x. size is bar width. Append u
if size is in y-units [Default is plot-distance units]. By default, base = xmin. Append b[base]
to change this value. If base is not appended then we read it from the last input data column.
-Sc circle. size is diameter of circle.
-Sd diamond. size is diameter of circumscribing circle.
-Se ellipse. Direction (in degrees counter-clockwise from horizontal), major_axis, and minor_axis
must be found in columns 3, 4, and 5.
-SE Same as -Se, except azimuth (in degrees east of north) should be given instead of direction.
The azimuth will be mapped into an angle based on the chosen map projection (-Se leaves the
directions unchanged.) Furthermore, the axes lengths must be given in geographical instead
of plot-distance units. An exception occurs for a linear projection in which we assume the
ellipse axes are given in the same units as -R. For degenerate ellipses (circles) with just the
diameter given, use -SE-. The diameter is excepted to be given in column 3. Alternatively,
append the desired diameter to -SE- and this fixed diameter is used instead. For allowable
geographical units, see UNITS.
1.75. psxy
275
-Sfgap[/size][+l|+r][+b+c+f+s+t][+ooffset][+p[pen]]. Draw a front. Supply distance gap between symbols and symbol size. If gap is negative, it is interpreted to mean the number
of symbols along the front instead. If size is missing it is set to 30% of the gap, except when
gap is negative and size is thus required. Append +l or +r to plot symbols on the left or
right side of the front [Default is centered]. Append +type to specify which symbol to plot:
box, circle, fault, slip, or triangle. [Default is fault]. Slip means left-lateral or right-lateral
strike-slip arrows (centered is not an option). The +s modifier optionally accepts the angle
used to draw the vector [20]. Alternatively, use +S which draws arcuate arrow heads. Append +ooffset to offset the first symbol from the beginning of the front by that amount [0].
The chosen symbol is drawn with the same pen as set for the line (i.e., via -W). The use an
alternate pen, append +ppen. To skip the outline, just use +p. Note: By placing -Sf options
in the segment header you can change the front types on a segment-by-segment basis.
-Sg octagon. size is diameter of circumscribing circle.
-Sh hexagon. size is diameter of circumscribing circle.
-Si inverted triangle. size is diameter of circumscribing circle.
-Sj Rotated rectangle. Direction (in degrees counter-clockwise from horizontal), x-dimension,
and y-dimension must be found in columns 3, 4, and 5.
-SJ Same as -Sj, except azimuth (in degrees east of north) should be given instead of direction.
The azimuth will be mapped into an angle based on the chosen map projection (-Sj leaves
the directions unchanged.) Furthermore, the dimensions must be given in geographical instead of plot-distance units. For a degenerate rectangle (square) with one dimension given,
use -SJ-. The dimension is excepted to be given in column 3. Alternatively, append the dimension diameter to -SJ- and this fixed dimension is used instead. An exception occurs for
a linear projection in which we assume the dimensions are given in the same units as -R. For
allowable geographical units, see UNITS.
-Sk kustom symbol. Append name/size, and we will look for a definition file called name.def in
(1) the current directory or (2) in ~/.gmt or (3) in $GMT_SHAREDIR/custom. The symbol
as defined in that file is of size 1.0 by default; the appended size will scale symbol accordingly. Users may add their own custom *.def files; see CUSTOM SYMBOLS below.
-Sl letter or text string (less than 256 characters). Give size, and append +tstring after the size.
Note that the size is only approximate; no individual scaling is done for different characters.
Remember to escape special characters like *. Optionally, you may append +ffont to select
a particular font [Default is FONT_ANNOT_PRIMARY] and +jjustify to change justification
[CM].
-Sm math angle arc, optionally with one or two arrow heads [Default is no arrow heads]. The size
is the length of the vector head. Arc width is set by -W. The radius of the arc and its start
and stop directions (in degrees counter-clockwise from horizontal) must be given in columns
3-5. See VECTOR ATTRIBUTES for specifying other attributes.
-SM Same as -Sm but switches to straight angle symbol if angles subtend 90 degrees exactly.
-Sn pentagon. size is diameter of circumscribing circle.
-Sp point. No size needs to be specified (1 pixel is used).
-Sq quoted line, i.e., lines with annotations such as contours. Append
[d|D|f|l|L|n|N|s|S|x|X]info[:labelinfo]. The required argument controls the placement
of labels along the quoted lines. Choose among six controlling algorithms:
276
ddist[c|i|p] or Ddist[d|e|f|k|m|M|n|s] For lower case d, give distances between labels on the plot in your preferred measurement unit c (cm), i (inch), or p
(points), while for upper case D, specify distances in map units and append
the unit; choose among e (m), f (foot), k (km), M (mile), n (nautical mile)
or u (US survey foot), and d (arc degree), m (arc minute), or s (arc second).
[Default is 10c or 4i]. As an option, you can append /fraction which is used to
place the very first label for each contour when the cumulative along-contour
distance equals fraction * dist [0.25].
fffile.d Reads the ASCII file ffile.d and places labels at locations in the file that
matches locations along the quoted lines. Inexact matches and points outside
the region are skipped.
l|Lline1[,line2,...] Give the coordinates of the end points for one or more
comma-separated straight line segments. Labels will be placed where
these lines intersect the quoted lines. The format of each line specification is start_lon/start_lat/stop_lon/stop_lat. Both start_lon/start_lat and
stop_lon/stop_lat can be replaced by a 2-character key that uses the justification format employed in pstext to indicate a point on the frame or center
of the map, given as [LCR][BMT]. L will interpret the point pairs as defining
great circles [Default is straight line].
n|Nn_label Specifies the number of equidistant labels for quoted lines [1]. Upper
case N starts labeling exactly at the start of the line [Default centers them along
the line]. N-1 places one justified label at start, while N+1 places one justified
label at the end of quoted lines. Optionally, append /min_dist[c|i|p] to enforce
that a minimum distance separation between successive labels is enforced.
s|Sn_label Same as n|Nn_label but implies that the input data are first to be converted into a series of 2-point line segments before plotting.
x|Xxfile.d Reads the multisegment file xfile.d and places labels at the intersections
between the quoted lines and the lines in xfile.d. X will resample the lines first
along great-circle arcs. In addition, you may optionally append +rradius[c|i|p]
to set a minimum label separation in the x-y plane [no limitation].
The optional labelinfo controls the specifics of the label formatting and consists of
a concatenated string made up of any of the following control arguments:
+aangle For annotations at a fixed angle, +an for line-normal, or +ap for lineparallel [Default].
+cdx[/dy] Sets the clearance between label and optional text box. Append c|i|p to
specify the unit or % to indicate a percentage of the label font size [15%].
+d Turns on debug which will draw helper points and lines to illustrate the workings of the quoted line setup.
+e Delay the plotting of the text. This is used to build a clip path based on the text,
then lay down other overlays while that clip path is in effect, then turning of
clipping with psclip -Cs which finally plots the original text.
+ffont Sets the desired font [Default FONT_ANNOT_PRIMARY with its size
changed to 9p].
+g[color] Selects opaque text boxes [Default is transparent]; optionally specify the
color [Default is PS_PAGE_COLOR].
1.75. psxy
277
+jjust Sets label justification [Default is MC]. Ignored when -SqN|n+|-1 is used.
+llabel Sets the constant label text.
+Lflag Sets the label text according to the specified flag:
+Lh Take the label from the current segment header (first scan for an embedded -Llabel option, if not use the first word following the segment flag).
For multiple-word labels, enclose entire label in double quotes. +Ld Take the
Cartesian plot distances along the line as the label; append c|i|p as the unit
[Default is PROJ_LENGTH_UNIT]. +LD Calculate actual map distances; append d|e|f|k|n|M|n|s as the unit [Default is d(egrees), unless label placement
was based on map distances along the lines in which case we use the same unit
specified for that algorithm]. Requires a map projection to be used. +Lf Use
text after the 2nd column in the fixed label location file as the label. Requires
the fixed label location setting. +Lx As +Lh but use the headers in the xfile.d
instead. Requires the crossing file option.
+ndx[/dy] Nudges the placement of labels by the specified amount (append c|i|p
to specify the units). Increments are considered in the coordinate system defined by the orientation of the line; use +N to force increments in the plot x/y
coordinates system [no nudging]. Not allowed with +v.
+o Selects rounded rectangular text box [Default is rectangular]. Not applicable
for curved text (+v) and only makes sense for opaque text boxes.
+p[pen] Draws the outline of text boxes [Default is no outline]; optionally specify
pen for outline [Default is width = 0.25p, color = black, style = solid].
+rmin_rad Will not place labels where the lines radius of curvature is less than
min_rad [Default is 0].
+t[file] Saves line label x, y, and text to file [Line_labels.txt]. Use +T to save x, y,
angle, text instead.
+uunit Appends unit to all line labels. If unit starts with a leading hyphen (-) then
there will be no space between label value and the unit. [Default is no unit].
+v Specifies curved labels following the path [Default is straight labels].
+w Specifies how many (x,y) points will be used to estimate label angles [Default
is 10].
+x[first,last] Append the suffices first and last to the corresponding labels. This
modifier is only available when -SqN2 is in effect. Used to annotate the start
and end of a line (e.g., a cross-section), append two text strings separated by
comma [Default just adds a prime to the second label].
+=prefix Prepends prefix to all line labels. If prefix starts with a leading hyphen (-)
then there will be no space between label value and the prefix. [Default is no
prefix].
Note: By placing -Sq options in the segment header you can change the quoted text attributes
on a segment-by-segment basis.
-Sr rectangle. No size needs to be specified, but the x- and y-dimensions must be found in
columns 3 and 4.
278
-SR Rounded rectangle. No size needs to be specified, but the x- and y-dimensions and corner
radius must be found in columns 3, 4, and 5.
-Ss square. size is diameter of circumscribing circle.
-St triangle. size is diameter of circumscribing circle.
-Sv vector. Direction (in degrees counter-clockwise from horizontal) and length must be found in
columns 3 and 4. The size is the length of the vector head. Vector width is set by -W. See
VECTOR ATTRIBUTES for specifying other attributes.
-SV Same as -Sv, except azimuth (in degrees east of north) should be given instead of direction.
The azimuth will be mapped into an angle based on the chosen map projection (-Sv leaves
the directions unchanged.) See VECTOR ATTRIBUTES for specifying other attributes.
-Sw pie wedge. Start and stop directions (in degrees counter-clockwise from horizontal) for pie
slice must be found in columns 3 and 4. Append +a to just draw the arc line or +r to just
draw the radial lines.
-SW Same as -Sw, except azimuths (in degrees east of north) should be given instead of the two
directions. The azimuths will be mapped into angles based on the chosen map projection
(-Sw leaves the directions unchanged.) For geo-wedges, specify size as a radial geographical
distance. For allowable geographical units, see UNITS. Append +a to just draw the arc or
+r to just draw the radial lines.
-Sx cross (x). size is diameter of circumscribing circle.
-Sy y-dash (|). size is the length of a short vertical (y-dir) line segment.
-S= geovector. Azimuth (in degrees east from north) and geographical length must be found in
columns 3 and 4. The size is the length of the vector head. Vector width is set by -W. See
VECTOR ATTRIBUTES for specifying attributes. Note: Geovector stems are drawn as thin
filled polygons and hence pen attributes like dashed and dotted are not available. For allowable geographical units, see UNITS.
-S~ decorated
line,
i.e.,
lines
with
symbols
along
them.
Append
[d|D|f|l|L|n|N|s|S|x|X]info[:symbolinfo]. The required argument controls the placement
of symbols along the decorated lines. Choose among six controlling algorithms:
ddist[c|i|p] or Ddist[d|e|f|k|m|M|n|s] For lower case d, give distances between
symbols on the plot in your preferred measurement unit c (cm), i (inch), or
p (points), while for upper case D, specify distances in map units and append
the unit; choose among e (m), f (foot), k (km), M (mile), n (nautical mile) or u
(US survey foot), and d (arc degree), m (arc minute), or s (arc second). [Default
is 10c or 4i]. As an option, you can append /fraction which is used to place the
very first symbol for each line when the cumulative along-line distance equals
fraction * dist [0.25].
fffile.d Reads the ASCII file ffile.d and places symbols at locations in the file that
matches locations along the decorated lines. Inexact matches and points outside the region are skipped.
l|Lline1[,line2,...] Give the coordinates of the end points for one or more
comma-separated straight line segments. Symbols will be placed where
these lines intersect the decorated lines. The format of each line specification is start_lon/start_lat/stop_lon/stop_lat. Both start_lon/start_lat and
stop_lon/stop_lat can be replaced by a 2-character key that uses the justification format employed in pstext to indicate a point on the frame or center
1.75. psxy
279
of the map, given as [LCR][BMT]. L will interpret the point pairs as defining
great circles [Default is straight line].
n|Nn_symbol Specifies the number of equidistant symbols for decorated lines [1].
Upper case N starts placing symbols exactly at the start of the line [Default
centers them along the line]. N-1 places one symbol at start, while N+1 places
one symbol at the end of decorated lines. Optionally, append /min_dist[c|i|p]
to enforce that a minimum distance separation between successive symbols is
enforced.
s|Sn_symbol Same as n|Nn_symbol but implies that the input data are first to be
converted into a series of 2-point line segments before plotting.
x|Xxfile.d Reads the multisegment file xfile.d and places symbols at the intersections between the decorated lines and the lines in xfile.d. X will resample the
lines first along great-circle arcs.
The optional symbolinfo controls the specifics of the symbol selection and formatting and consists of a concatenated string made up of any of the following control
arguments:
+aangle For symbols at a fixed angle, +an for line-normal, or +ap for line-parallel
[Default].
+d Turns on debug which will draw helper points and lines to illustrate the workings of the decorated line setup.
+g[fill] Sets the symbol fill [no fill].
+ndx[/dy] Nudges the placement of symbols by the specified amount (append c|i|p
to specify the units). Increments are considered in the coordinate system defined by the orientation of the line; use +N to force increments in the plot x/y
coordinates system [no nudging].
+p[pen] Draws the outline of symbols [Default is no outline]; optionally specify
pen for outline [Default is width = 0.25p, color = black, style = solid].
+s<symbol><size> Specifies the code and size of the decorative symbol.
+w Specifies how many (x,y) points will be used to estimate symbol angles [Default is 10].
Note: By placing -S~ options in the segment header you can change the decorated lines on a
segment-by-segment basis.
-T Ignore all input files, including standard input. This is the same as specifying /dev/null (or NUL for
Windows users) as input file. Use this to activate only the options that are not related to plotting of
lines or symbols, such as psxy -R -J -O -T to terminate a sequence of GMT plotting commands
without producing any plotting output.
-U[just/dx/dy/][c|label] (more ...) Draw GMT time stamp logo on plot.
-V[level] (more ...) Select verbosity level [c].
-W[pen][attr] (more ...) Set pen attributes for lines or the outline of symbols [Defaults: width = default,
color = black, style = solid]. If the modifier +cl is appended then the color of the line are taken
from the CPT (see -C). If instead modifier +cf is appended then the color from the cpt file is
applied to symbol fill. Use just +c for both effects. You can also append one or more additional
line attribute modifiers: +ooffsetu will start and stop drawing the line the given distance offsets
280
from the end point. Append unit u from c|i|p to indicate plot distance on the map or append map
distance units instead (see below) [Cartesian distances]; +s will draw the line using a PostScript
Bezier spline [linear spline]; +vvspecs will place a vector head at the ends of the lines. You can
use +vb and +ve to specify separate vector specs at each end [shared specs]. Because +v may take
additional modifiers it must necessarily be given at the end of the pen specification. See the Vector
Attributes for more information.
-X[a|c|f|r][x-shift[u]]
-Y[a|c|f|r][y-shift[u]] (more ...) Shift plot origin.
-bi[ncols][t] (more ...) Select native binary input. [Default is the required number of columns given the
chosen settings].
-acol=name[...] (more ...) Set aspatial column associations col=name.
-ccopies (more ...) Specify number of plot copies [Default is 1].
-dinodata (more ...) Replace input columns that equal nodata with NaN.
-f[i|o]colinfo (more ...) Specify data types of input and/or output columns.
-g[a]x|y|d|X|Y|D|[col]z[+|-]gap[u] (more ...) Determine data gaps and line breaks. The -g option is ignored if -S is set.
-h[i|o][n][+c][+d][+rremark][+rtitle] (more ...) Skip or produce header record(s).
-icols[l][sscale][ooffset][,...] (more ...) Select input columns (0 is first column).
-:[i|o] (more ...) Swap 1st and 2nd column on input and/or output.
-p[x|y|z]azim/elev[/zlevel][+wlon0/lat0[/z0]][+vx0/y0] (more ...) Select perspective view.
-t[transp] (more ...) Set PDF transparency level in percent.
-^ or just - Print a short message about the syntax of the command, then exits (NOTE: on Windows use
just -).
-+ or just + Print an extensive usage (help) message, including the explanation of any module-specific
option (but not the GMT common options), then exits.
-? or no arguments Print a complete usage (help) message, including the explanation of options, then
exits.
1.75.5 Units
For map distance unit, append unit d for arc degree, m for arc minute, and s for arc second, or e for
meter [Default], f for foot, k for km, M for statute mile, n for nautical mile, and u for US survey foot.
By default we compute such distances using a spherical approximation with great circles. Prepend - to
a distance (or the unit is no distance is given) to perform Flat Earth calculations (quicker but less
accurate) or prepend + to perform exact geodesic calculations (slower but more accurate).
1.75. psxy
281
1.75.7 Examples
To plot solid red circles (diameter = 0.25 cm) at the positions listed in the file DSDP.xy on a Mercator
map at 5 cm/degree of the area 150E to 154E, 18N to 23N, with tick-marks every 1 degree and gridlines
every 15 minutes, use
282
gmt psxy DSDP.xy R150/154/18/23 -Jm5c -Sc0.25c -Gred -B1g15m > map.ps
To plot the xyz values in the file quakes.xyzm as circles with size given by the magnitude in the 4th
column and color based on the depth in the third using the CPT rgb.cpt on a linear map, use
gmt psxy quakes.xyzm -R0/1000/0/1000 -JX6i -Sc -Crgb -B200 > map.ps
To plot the file trench.txt on a Mercator map, with white triangles with sides 0.25 inch on the left side of
the line, spaced every 0.8 inch, use
gmt psxy trench.txt -R150/200/20/50 -Jm0.15i -Sf0.8i/0.1i+l+t -Gwhite -W -B10 >
map.ps
To plot the data in the file misc.d as symbols determined by the code in the last column, and with size
given by the magnitude in the 4th column, and color based on the third column via the CPT chrome on
a linear map, use
gmt psxy misc.d -R0/100/-50/100 -JX6i -S -Cchrome -B20 > map.ps
If you need to place vectors on a plot you can choose among straight Cartesian vectors, math circular
vectors, or geo-vectors (these form small or great circles on the Earth). These can have optional heads
at either end, and heads may be the traditional arrow, a circle, or a terminal cross-line. To place a few
vectors with a circle at the start location and an arrow head at the end, try
gmt psxy -R0/50/-50/50 -JX6i -Sv0.15i+bc+ea -Gyellow -W0.5p -Baf << EOF > map.ps
10 10 45 2i
30 -20 0 1.5i
EOF
To plot vectors (red vector heads, solid stem) from the file data.txt that contains record of the form lon,
lat, dx, dy, where dx, dy are the Cartesian vector components given in user units, and these user units
should be converted to cm given the scale 3.60, try
gmt psxy -R20/40/-20/0 -JM6i -Sv0.15i+e+z3.6c -Gred -W0.25p -Baf data.txt > map.ps
1.75. psxy
283
1.76 psxyz
psxyz - Plot lines, polygons, and symbols in 3-D
1.76.1 Synopsis
psxyz [ table ] -Jparameters -Jz|Zparameters -Rwest/east/south/north[/zmin/zmax][r] [ B[p|s]parameters ] [ -Ddx/dy[/dz] ] [ -Gfill ] [ -Iintens ] [ -K ] [ -L[+b|d|D][+xl|r|x0][+yl|r|y0][+ppen]
] [ -N ] [ -O ] [ -P ] [ -Q ] [ -S[symbol][size[unit]][/size_y] ] [ -T ] [ -U[stamp] ] [ -V[level] ] [
-W[pen][attr] ] [ -Xx_offset ] [ -Yy_offset ] [ -aflags ] [ -bibinary ] [ -ccopies ] [ -dinodata ] [ -fflags ] [
-ggaps ] [ -hheaders ] [ -iflags ] [ -pflags ] [ -ttransp ] [ -:[i|o] ]
Note: No space is allowed between the option flag and the associated arguments.
1.76.2 Description
psxyz reads (x,y,z) triplets from files [or standard input] and generates PostScript code that will plot
lines, polygons, or symbols at those locations in 3-D. If a symbol is selected and no symbol size given,
then psxyz will interpret the fourth column of the input data as symbol size. Symbols whose size is
<= 0 are skipped. If no symbols are specified then the symbol code (see -S below) must be present as
last column in the input. If -S is not used, a line connecting the data points will be drawn instead. To
explicitly close polygons, use -L. Select a fill with -G. If -G is set, -W will control whether the polygon
outline is drawn or not. If a symbol is selected, -G and -W determines the fill and outline/no outline,
respectively. The PostScript code is written to standard output.
285
point, respectively [Default is PROJ_LENGTH_UNIT]. Note: if you give both size and symbol
via the input file you must use PROJ_LENGTH_UNIT to indicate the units used for the symbol
size or append the units to the size in the file. Some 2-dimensional symbols optionally take a
second size via size_y. If symbol sizes are expected via the fourth data column then you may
convert those values to suitable symbol sizes via the -i mechanism.
The uppercase symbols A, C, D, G, H, I, N, S, T are normalized to have the same area as a circle
with diameter size, while the size of the corresponding lowercase symbols refers to the diameter
of a circumscribed circle.
You can change symbols by adding the required -S option to any of your multisegment headers.
Choose between these symbol codes:
-S- x-dash (-). size is the length of a short horizontal (x-dir) line segment.
-S+ plus (+). size is diameter of circumscribing circle.
-Sa star. size is diameter of circumscribing circle.
-Sb Vertical bar extending from base to y. size is bar width. Append u if size is in x-units [Default
is plot-distance units]. By default, base = ymin. Append b[base] to change this value. If base
is not appended then we read it from the last input data column.
-SB Horizontal bar extending from base to x. size is bar width. Append u if size is in y-units
[Default is plot-distance units]. By default, base = xmin. Append b[base] to change this
value. If base is not appended then we read it from the last input data column.
-Sc circle. size is diameter of circle.
-Sd diamond. size is diameter of circumscribing circle.
-Se ellipse. Direction (in degrees counter-clockwise from horizontal), major_axis, and minor_axis
must be found in columns 4, 5, and 6.
-SE Same as -Se, except azimuth (in degrees east of north) should be given instead of direction.
The azimuth will be mapped into an angle based on the chosen map projection (-Se leaves the
directions unchanged.) Furthermore, the axes lengths must be given in geographical instead
of plot-distance units. An exception occurs for a linear projection in which we assume the
ellipse axes are given in the same units as -R. For degenerate ellipses (circles) with just the
diameter given, use -SE-. The diameter is excepted to be given in column 4. Alternatively,
append the desired diameter to -SE- and this fixed diameter is used instead. For allowable
geographical units, see UNITS.
-Sf front. -Sfgap[/size][+l|+r][+b+c+f+s+t][+ooffset][+p[pen]]. Supply distance gap between
symbols and symbol size. If gap is negative, it is interpreted to mean the number of symbols
along the front instead. If size is missing it is set to 30% of the gap, except when gap is negative and size is thus required. Append +l or +r to plot symbols on the left or right side of the
front [Default is centered]. Append +type to specify which symbol to plot: box, circle, fault,
slip, or triangle. [Default is fault]. Slip means left-lateral or right-lateral strike-slip arrows
(centered is not an option). The +s modifier optionally accepts the angle used to draw the
vector [30]. Append +ooffset to offset the first symbol from the beginning of the front by that
amount [0]. The chosen symbol is drawn with the same pen as set for the line (i.e., via -W).
The use an alternate pen, append +ppen. To skip the outline, just use +p. Note: By placing
-Sf options in the segment header you can change the front types on a segment-by-segment
basis.
-Sg octagon. size is diameter of circumscribing circle.
286
1.76. psxyz
287
fffile.d Reads the ASCII file ffile.d and places labels at locations in the file that
matches locations along the quoted lines. Inexact matches and points outside the
region are skipped. l|Lline1[,*line2*,...] Give start and stop coordinates for one or
more comma-separated straight line segments. Labels will be placed where these
lines intersect the quoted lines. The format of each line specification is start/stop,
where start and stop are either a specified point lon/lat or a 2-character XY key
that uses the justification format employed in pstext to indicate a point on the map,
given as [LCR][BMT]. L will interpret the point pairs as defining great circles [Default is straight line]. nn_label Specifies the number of equidistant labels for quoted
lines line [1]. Upper case N starts labeling exactly at the start of the line [Default
centers them along the line]. N-1 places one justified label at start, while N+1 places
one justified label at the end of quoted lines. Optionally, append /min_dist[c|i|p] to
enforce that a minimum distance separation between successive labels is enforced.
x|Xxfile.d Reads the multisegment file xfile.d and places labels at the intersections
between the quoted lines and the lines in xfile.d. X will resample the lines first
along great-circle arcs. In addition, you may optionally append +rradius[c|i|p] to
set a minimum label separation in the x-y plane [no limitation].
The optional labelinfo controls the specifics of the label formatting and consists of
a concatenated string made up of any of the following control arguments:
+aangle For annotations at a fixed angle, +an for line-normal, or +ap for lineparallel [Default].
+cdx[/dy] Sets the clearance between label and optional text box. Append c|i|p to
specify the unit or % to indicate a percentage of the label font size [15%].
+d Turns on debug which will draw helper points and lines to illustrate the workings of the quoted line setup.
+e Delay the plotting of the text. This is used to build a clip path based on the text,
then lay down other overlays while that clip path is in effect, then turning of
clipping with psclip -Cs which finally plots the original text.
+ffont Sets the desired font [Default FONT_ANNOT_PRIMARY with its size
changed to 9p].
+g[color] Selects opaque text boxes [Default is transparent]; optionally specify the
color [Default is PS_PAGE_COLOR].
+jjust Sets label justification [Default is MC]. Ignored when -SqN|n+|-1 is used.
+llabel Sets the constant label text.
+Lflag Sets the label text according to the specified flag:
+Lh Take the label from the current segment header (first scan for an embedded -Llabel option, if not use the first word following the segment flag).
For multiple-word labels, enclose entire label in double quotes. +Ld Take the
Cartesian plot distances along the line as the label; append c|i|p as the unit
[Default is PROJ_LENGTH_UNIT]. +LD Calculate actual map distances;
append d|e|f|k|n|M|n|s as the unit [Default is d(egrees), unless label placement
was based on map distances along the lines in which case we use the same unit
specified for that algorithm]. Requires a map projection to be used. +Lf Use
text after the 2nd column in the fixed label location file as the label. Requires
the fixed label location setting. +Lx As +Lh but use the headers in the xfile.d
instead. Requires the crossing file option.
288
+ndx[/dy] Nudges the placement of labels by the specified amount (append c|i|p
to specify the units). Increments are considered in the coordinate system defined by the orientation of the line; use +N to force increments in the plot x/y
coordinates system [no nudging]. Not allowed with +v.
+o Selects rounded rectangular text box [Default is rectangular]. Not applicable
for curved text (+v) and only makes sense for opaque text boxes.
+p[pen] Draws the outline of text boxes [Default is no outline]; optionally specify
pen for outline [Default is width = 0.25p, color = black, style = solid].
+rmin_rad Will not place labels where the lines radius of curvature is less than
min_rad [Default is 0].
+t[file] Saves line label x, y, and text to file [Line_labels.txt]. Use +T to save x, y,
angle, text instead.
+uunit Appends unit to all line labels. If unit starts with a leading hyphen (-) then
there will be no space between label value and the unit. [Default is no unit].
+v Specifies curved labels following the path [Default is straight labels].
+w Specifies how many (x,y) points will be used to estimate label angles [Default
is 10].
+=prefix Prepends prefix to all line labels. If prefix starts with a leading hyphen (-)
then there will be no space between label value and the prefix. [Default is no
prefix].
Note: By placing -Sq options in the segment header you can change the quoted text attributes
on a segment-by-segment basis.
-Sr rectangle. No size needs to be specified, but the x- and y-dimensions must be found in
columns 4 and 5.
-SR Rounded rectangle. No size needs to be specified, but the x- and y-dimensions and corner
radius must be found in columns 4, 5, and 6.
-Ss square. size is diameter of circumscribing circle.
-St triangle. size is diameter of circumscribing circle.
-Su cube (3-D). The size) sets length of all sides. Append u if size is in x-units [Default is plotdistance units]. The facet colors will be modified to simulate shading. Use -SU to disable
such 3-D illumination.
-Sv vector. Direction (in degrees counter-clockwise from horizontal) and length must be found in
columns 4 and 5. The size is the length of the vector head. Vector width is set by -W. See
VECTOR ATTRIBUTES for specifying attributes.
-SV Same as -Sv, except azimuth (in degrees east of north) should be given instead of direction.
The azimuth will be mapped into an angle based on the chosen map projection (-Sv leaves
the directions unchanged.) See VECTOR ATTRIBUTES for specifying attributes.
-Sw pie wedge. Start and stop directions (in degrees counter-clockwise from horizontal) for pie
slice must be found in columns 4 and 5. Append +a to just draw the arc line or +r to just
draw the radial lines.
-SW Same as -Sw, except azimuths (in degrees east of north) should be given instead of the two
directions. The azimuths will be mapped into angles based on the chosen map projection
1.76. psxyz
289
(-Sw leaves the directions unchanged.) For geo-wedges, specify size as a radial distance and
append a length unit from d|m|s|e|f|k|M|n|u. Append +a to just draw the arc or +r to just
draw the radial lines.
-Sx cross (x). size is diameter of circumscribing circle.
-Sy y-dash (|). size is the length of a short horizontal (y-dir) line segment.
-S= geovector. Azimuth (in degrees east from north) and length (in km) must be found in columns
4 and 5. The size is the length of the vector head. Vector width is set by -W. See VECTOR
ATTRIBUTES for specifying attributes. Note: Geovector stems are drawn as thin filled polygons and hence pen attributes like dashed and dotted are not available.
-S~ decorated
line,
i.e.,
lines
with
symbols
along
them.
Append
[d|D|f|l|L|n|N|s|S|x|X]info[:symbolinfo]. The required argument controls the placement
of symbols along the decorated lines. Choose among six controlling algorithms:
ddist[c|i|p] or Ddist[d|e|f|k|m|M|n|s] For lower case d, give distances between
symbols on the plot in your preferred measurement unit c (cm), i (inch), or
p (points), while for upper case D, specify distances in map units and append
the unit; choose among e (m), f (foot), k (km), M (mile), n (nautical mile) or u
(US survey foot), and d (arc degree), m (arc minute), or s (arc second). [Default
is 10c or 4i]. As an option, you can append /fraction which is used to place the
very first symbol for each line when the cumulative along-line distance equals
fraction * dist [0.25].
fffile.d Reads the ASCII file ffile.d and places symbols at locations in the file that
matches locations along the decorated lines. Inexact matches and points outside the region are skipped.
l|Lline1[,line2,...] Give the coordinates of the end points for one or more
comma-separated straight line segments. Symbols will be placed where
these lines intersect the decorated lines. The format of each line specification is start_lon/start_lat/stop_lon/stop_lat. Both start_lon/start_lat and
stop_lon/stop_lat can be replaced by a 2-character key that uses the justification format employed in pstext to indicate a point on the frame or center
of the map, given as [LCR][BMT]. L will interpret the point pairs as defining
great circles [Default is straight line].
n|Nn_symbol Specifies the number of equidistant symbols for decorated lines [1].
Upper case N starts placing symbols exactly at the start of the line [Default
centers them along the line]. N-1 places one symbol at start, while N+1 places
one symbol at the end of decorated lines. Optionally, append /min_dist[c|i|p]
to enforce that a minimum distance separation between successive symbols is
enforced.
s|Sn_symbol Same as n|Nn_symbol but implies that the input data are first to be
converted into a series of 2-point line segments before plotting.
x|Xxfile.d Reads the multisegment file xfile.d and places symbols at the intersections between the decorated lines and the lines in xfile.d. X will resample the
lines first along great-circle arcs.
The optional symbolinfo controls the specifics of the symbol selection and formatting and consists of a concatenated string made up of any of the following control
arguments:
290
+aangle For symbols at a fixed angle, +an for line-normal, or +ap for line-parallel
[Default].
+d Turns on debug which will draw helper points and lines to illustrate the workings of the decorated line setup.
+g[fill] Sets the symbol fill [no fill].
+ndx[/dy] Nudges the placement of symbols by the specified amount (append c|i|p
to specify the units). Increments are considered in the coordinate system defined by the orientation of the line; use +N to force increments in the plot x/y
coordinates system [no nudging].
+p[pen] Draws the outline of symbols [Default is no outline]; optionally specify
pen for outline [Default is width = 0.25p, color = black, style = solid].
+w Specifies how many (x,y) points will be used to estimate symbol angles [Default is 10].
Note: By placing -S~ options in the segment header you can change the decorated lines on a
segment-by-segment basis.
-T Ignore all input files, including standard input. This is the same as specifying /dev/null (or NUL for
Windows users) as input file. Use this to activate only the options that are not related to plotting of
lines or symbols, such as psxyz -R -J -O -T to terminate a sequence of GMT plotting commands
without producing any plotting output.
-U[just/dx/dy/][c|label] (more ...) Draw GMT time stamp logo on plot.
-V[level] (more ...) Select verbosity level [c].
-W[pen][attr] (more ...) Set pen attributes for lines or the outline of symbols [Defaults: width = default,
color = black, style = solid]. If the modifier +cl is appended then the color of the line are taken
from the CPT (see -C). If instead modifier +cf is appended then the color from the cpt file is
applied to symbol fill. Use just +c for both effects.
-X[a|c|f|r][x-shift[u]]
-Y[a|c|f|r][y-shift[u]] (more ...) Shift plot origin.
-acol=name[...] (more ...) Set aspatial column associations col=name.
-bi[ncols][t] (more ...) Select native binary input. [Default is the required number of columns given the
chosen settings].
-ccopies (more ...) Specify number of plot copies [Default is 1].
-dinodata (more ...) Replace input columns that equal nodata with NaN.
-f[i|o]colinfo (more ...) Specify data types of input and/or output columns.
-g[a]x|y|d|X|Y|D|[col]z[+|-]gap[u] (more ...) Determine data gaps and line breaks. The -g option is ignored if -S is set.
-h[i|o][n][+c][+d][+rremark][+rtitle] (more ...) Skip or produce header record(s).
-icols[l][sscale][ooffset][,...] (more ...) Select input columns (0 is first column).
-p[x|y|z]azim/elev[/zlevel][+wlon0/lat0[/z0]][+vx0/y0] (more ...) Select perspective view.
-t[transp] (more ...) Set PDF transparency level in percent.
-:[i|o] (more ...) Swap 1st and 2nd column on input and/or output.
1.76. psxyz
291
-^ or just - Print a short message about the syntax of the command, then exits (NOTE: on Windows use
just -).
-+ or just + Print an extensive usage (help) message, including the explanation of any module-specific
option (but not the GMT common options), then exits.
-? or no arguments Print a complete usage (help) message, including the explanation of options, then
exits.
1.76.5 Units
For map distance unit, append unit d for arc degree, m for arc minute, and s for arc second, or e for
meter [Default], f for foot, k for km, M for statute mile, n for nautical mile, and u for US survey foot.
By default we compute such distances using a spherical approximation with great circles. Prepend - to
a distance (or the unit is no distance is given) to perform Flat Earth calculations (quicker but less
accurate) or prepend + to perform exact geodesic calculations (slower but more accurate).
292
+r draws half-arrows, using only the right side of specified heads [both sides].
t[b|e]trim will shift the beginning or end point (or both) along the vector segment by the
given trim; append suitable unit. If the modifiers b|e are not used then trim may be two
values separated by a slash, which is used to specify different trims for the two ends. Positive
trims will shorted the vector while negative trims will lengthen it [no trim].
In addition, all but circular vectors may take these modifiers:
+jjust determines how the input x,y point relates to the vector. Choose from beginning
[default], end, or center.
+s means the input angle, length are instead the x, y coordinates of the vector end point.
Finally, Cartesian vectors may take these modifiers:
+zscale[unit] expects input dx,dy vector components and uses the scale to convert to polar
coordinates with length in given unit.
1.76.7 Examples
To plot blue columns (width = 1.25 cm) at the positions listed in the file heights.xyz on a 3-D projection
of the space (0-10), (0-10), (0-100), with tickmarks every 2, 2, and 10, viewing it from the southeast at
30 degree elevation, use:
gmt psxyz heights.xyz -R0/10/0/10/0/100 -Jx1.25c -Jz0.125c -So1.25c \
-Gblue -Bx2+lXLABEL -By2+lYLABEL -Bz10+lZLABEL -B+t"3-D PLOT" -p135/30 \
-Uc -W -P > heights.ps
293
the $GMT_SHAREDIR/custom directory, in that order. Freeform polygons (made up of straight line
segments and arcs of circles) can be designed - these polygons can be painted and filled with a pattern.
Other standard geometric symbols can also be used. See Appendix App-custom_symbols for macro
definitions.
1.76.10 Bugs
No hidden line removal is employed for polygons and lines. Symbols, however, are first sorted according
to their distance from the viewpoint so that nearby symbols will overprint more distant ones should they
project to the same x,y position.
psxyz cannot handle filling of polygons that contain the south or north pole. For such a polygon, make
a copy and split it into two and make each explicitly contain the polar point. The two polygons will
combine to give the desired effect when filled; to draw outline use the original polygon.
1.77 sample1d
sample1d - Resample 1-D table data using splines
1.77.1 Synopsis
sample1d [ table ] [ -Af|p|m|r|R[+l] ] [ -Fl|a|c|n[+1|+2] ] [ -Iinc[unit] ] [ -Nknotfile ] [ -Sstart[/stop] ] [
-Tcol ] [ -V[level] ] [ -bbinary ] [ -dnodata ] [ -fflags ] [ -ggaps ] [ -hheaders ] [ -iflags ] [ -oflags ]
Note: No space is allowed between the option flag and the associated arguments.
1.77.2 Description
sample1d reads a multi-column ASCII [or binary] data set from file [or standard input] and interpolates
the time-series or spatial profile at locations where the user needs the values. The user must provide
the column number of the independent (monotonically increasing or decreasing) variable, here called
time (it may of course be any type of quantity). Equidistant or arbitrary sampling can be selected. All
columns are resampled based on the new sampling interval. Several interpolation schemes are available.
Extrapolation outside the range of the input data is not supported.
294
295
-? or no arguments Print a complete usage (help) message, including the explanation of options, then
exits.
1.77.5 Units
For map distance unit, append unit d for arc degree, m for arc minute, and s for arc second, or e for
meter [Default], f for foot, k for km, M for statute mile, n for nautical mile, and u for US survey foot.
By default we compute such distances using a spherical approximation with great circles. Prepend - to
a distance (or the unit is no distance is given) to perform Flat Earth calculations (quicker but less
accurate) or prepend + to perform exact geodesic calculations (slower but more accurate).
1.77.8 Examples
To resample the file profiles.tdgmb, which contains (time,distance,gravity,magnetics,bathymetry)
records, at 1km equidistant intervals using Akimas spline, use
gmt sample1d profiles.tdgmb -I1 -Fa -T1 > profiles_equi_d.tdgmb
To resample the file depths.dt at positions listed in the file grav_pos.dg, using a cubic spline for the
interpolation, use
gmt sample1d depths.dt -Ngrav_pos.dg -Fc > new_depths.dt
To resample the file points.txt every 0.01 from 0-6, using a cubic spline for the interpolation, but output
the first derivative instead (the slope), try
gmt sample1d points.txt S0/6 -I0.01 -Fc+1 > slopes.txt
To resample the file track.txt which contains lon, lat, depth every 2 nautical miles, use
gmt sample1d track.txt -I2n -AR > new_track.dt
To do approximately the same, but make sure the original points are included, use
gmt sample1d track.txt -I2n -Af > new_track.dt
296
1.78 spectrum1d
spectrum1d - Compute auto- [and cross- ] spectra from one [or two] time-series
1.78.1 Synopsis
spectrum1d [ table ] -Ssegment_size] [ -C[xycnpago] ] [ -Ddt ] [ -L[h|m] ] [ -N[name_stem ] ] [ -T ] [
-W ] [ -bbinary ] [ -dnodata ] [ -fflags ] [ -ggaps ] [ -hheaders ] [ -iflags ]
Note: No space is allowed between the option flag and the associated arguments.
1.78.2 Description
spectrum1d reads X [and Y] values from the first [and second] columns on standard input [or x[y]file].
These values are treated as timeseries X(t) [Y(t)] sampled at equal intervals spaced dt units apart. There
may be any number of lines of input. spectrum1d will create file[s] containing auto- [and cross- ]
spectral density estimates by Welchs method of ensemble averaging of multiple overlapped windows,
using standard error estimates from Bendat and Piersol.
The output files have 3 columns: f or w, p, and e. f or w is the frequency or wavelength, p is the spectral
density estimate, and e is the one standard deviation error bar size. These files are named based on
name_stem. If the -C option is used, up to eight files are created; otherwise only one (xpower) is written.
The files (which are ASCII unless -bo is set) are as follows:
name_stem.xpower Power spectral density of X(t). Units of X * X * dt.
name_stem.ypower Power spectral density of Y(t). Units of Y * Y * dt.
name_stem.cpower Power spectral density of the coherent output. Units same as ypower.
name_stem.npower Power spectral density of the noise output. Units same as ypower.
name_stem.gain Gain spectrum, or modulus of the transfer function. Units of (Y / X).
name_stem.phase Phase spectrum, or phase of the transfer function. Units are radians.
name_stem.admit Admittance spectrum, or real part of the transfer function. Units of (Y / X).
name_stem.coh (Squared) coherency spectrum, or linear correlation coefficient as a function of frequency. Dimensionless number in [0, 1]. The Signal-to-Noise-Ratio (SNR) is coh / (1 - coh). SNR
= 1 when coh = 0.5.
In addition, a single file with all of the above as individual columns will be written to stdout (unless
disabled via -T).
1.78. spectrum1d
297
298
1.78.6 Examples
Suppose data.g is gravity data in mGal, sampled every 1.5 km. To write its power spectrum, in mGal**2km, to the file data.xpower, use
gmt spectrum1d data.g -S256 -D1.5 -Ndata
Suppose in addition to data.g you have data.t, which is topography in meters sampled at the same points
as data.g. To estimate various features of the transfer function, considering data.t as input and data.g as
output, use
paste data.t data.g | gmt spectrum1d -S256 -D1.5 -Ndata -C > results.txt
1.78.7 Tutorial
The output of spectrum1d is in units of power spectral density, and so to get units of data-squared you
must divide by delta_t, where delta_t is the sample spacing. (There may be a factor of 2 pi somewhere,
also. If you want to be sure of the normalization, you can determine a scale factor from Parsevals
theorem: the sum of the squares of your input data should equal the sum of the squares of the outputs
from spectrum1d, if you are simply trying to get a periodogram. [See below.])
Suppose we simply take a data set, x(t), and compute the discrete Fourier transform (DFT) of the entire
data set in one go. Call this X(f). Then suppose we form X(f) times the complex conjugate of X(f).
P_raw(f) = X(f) * X(f), where the indicates complex conjugation.
P_raw is called the periodogram. The sum of the samples of the periodogram equals the sum of the
samples of the squares of x(t), by Parsevals theorem. (If you use a DFT subroutine on a computer,
usually the sum of P_raw equals the sum of x-squared, times M, where M is the number of samples in
x(t).)
Each estimate of X(f) is now formed by a weighted linear combination of all of the x(t) values. (The
weights are sometimes called twiddle factors in the DFT literature.) So, no matter what the probability
distribution for the x(t) values is, the probability distribution for the X(f) values approaches [complex]
Gaussian, by the Central Limit Theorem. This means that the probability distribution for P_raw(f) approaches chi-squared with two degrees of freedom. That reduces to an exponential distribution, and the
variance of the estimate of P_raw is proportional to the square of the mean, that is, the expected value
of P_raw.
In practice if we form P_raw, the estimates are hopelessly noisy. Thus P_raw is not useful, and we need
to do some kind of smoothing or averaging to get a useful estimate, P_useful(f).
There are several different ways to do this in the literature. One is to form P_raw and then smooth it.
Another is to form the auto-covariance function of x(t), smooth, taper and shape it, and then take the
1.78. spectrum1d
299
Fourier transform of the smoothed, tapered and shaped auto-covariance. Another is to form a parametric
model for the auto-correlation structure in x(t), then compute the spectrum of that model. This last
approach is what is done in what is called the maximum entropy or Berg or Box-Jenkins or
ARMA or ARIMA methods.
Welchs method is a tried-and-true method. In his method, you choose a segment length, -SN, so that
estimates will be made from segments of length N. The frequency samples (in cycles per delta_t unit) of
your P_useful will then be at k /(N * delta_t), where k is an integer, and you will get N samples (since
the spectrum is an even function of f, only N/2 of them are really useful). If the length of your entire data
set, x(t), is M samples long, then the variance in your P_useful will decrease in proportion to N/M. Thus
you need to choose N << M to get very low noise and high confidence in P_useful. There is a trade-off
here; see below.
There is an additional reduction in variance in that Welchs method uses a Von Hann spectral window on
each sample of length N. This reduces side lobe leakage and has the effect of smoothing the (N segment)
periodogram as if the X(f) had been convolved with [1/4, 1/2, 1/4] prior to forming P_useful. But this
slightly widens the spectral bandwidth of each estimate, because the estimate at frequency sample k is
now a little correlated with the estimate at frequency sample k+1. (Of course this would also happen if
you simply formed P_raw and then smoothed it.)
Finally, Welchs method also uses overlapped processing. Since the Von Hann window is large in the
middle and tapers to near zero at the ends, only the middle of the segment of length N contributes much
to its estimate. Therefore in taking the next segment of data, we move ahead in the x(t) sequence only
N/2 points. In this way, the next segment gets large weight where the segments on either side of it will
get little weight, and vice versa. This doubles the smoothing effect and ensures that (if N << M) nearly
every point in x(t) contributes with nearly equal weight in the final answer.
Welchs method of spectral estimation has been widely used and widely studied. It is very reliable and
its statistical properties are well understood. It is highly recommended in such textbooks as Random
Data: Analysis and Measurement Procedures by Bendat and Piersol.
In all problems of estimating parameters from data, there is a classic trade-off between resolution and
variance. If you want to try to squeeze more resolution out of your data set, then you have to be willing
to accept more noise in the estimates. The same trade-off is evident here in Welchs method. If you
want to have very low noise in the spectral estimates, then you have to choose N << M, and this means
that you get only N samples of the spectrum, and the longest period that you can resolve is only N *
delta_t. So you see that reducing the noise lowers the number of spectral samples and lowers the longest
period. Conversely, if you choose N approaching M, then you approach the periodogram with its very
bad statistical properties, but you get lots of samples and a large fundamental period.
The other spectral estimation methods also can do a good job. Welchs method was selected because the
way it works, how one can code it, and its effects on statistical distributions, resolution, side-lobe leakage, bias, variance, etc. are all easily understood. Some of the other methods (e.g. Maximum Entropy)
tend to hide where some of these trade-offs are happening inside a black box.
1.78.9 References
Bendat, J. S., and A. G. Piersol, 1986, Random Data, 2nd revised ed., John Wiley & Sons.
300
Welch, P. D., 1967, The use of Fast Fourier Transform for the estimation of power spectra: a method
based on time averaging over short, modified periodograms, IEEE Transactions on Audio and Electroacoustics, Vol AU-15, No 2.
1.79 sph2grd
sph2grd - Compute grid from spherical harmonic coefficients
1.79.1 Synopsis
sph2grd [ table ] -Ggrdfile -Iincrement -Rregion [ -D[g|n] ] [ -E ] [ -F[k]filter ] [ -N[norm] ] [ -Q ] [
-V[level] ] [ -bibinary ] [ -hheaders ] [ -iflags ] [ -r ] [ -x[[-]n] ]
Note: No space is allowed between the option flag and the associated arguments.
1.79.2 Description
sph2grd reads a spherical harmonics coefficient table with records of L, M, C[L,M], S[L,M] and evaluates the spherical harmonic model on the specified grid.
1.79. sph2grd
301
meaning of ? in your shell program by putting a backslash in front of it, or by placing the filename and
suffix between quotes or double quotes.
1.79.8 Examples
To create a 1 x 1 degree global grid file from the ASCII coefficients in EGM96_to_360.txt, use
gmt sph2grd EGM96_to_360.txt -GEGM96_to_360.nc -Rg -I1 -V
1.79.9 Reference
Holmes, S. A., and Featherstone, W. E., 2002, A unified approach to the Clenshaw summation and
the recursive computation of very high degree and order normalized associated Legendre functions: J.
Geodesy, v. 76, p. 279-299.
1.80 sphdistance
sphdistance - Create Voronoi distance, node, or nearest-neighbor grid on a sphere
1.80.1 Synopsis
sphdistance [ table ] -Ggrdfile [ -C ] [ -Ed|n|z[dist] ] [ -Iincrement ] [ -Lunit ] [ -Nnodetable ] [ Qvoronoi.txt ] [ -Rregion ] [ -V[level] ] [ -bbinary ] [ -dnodata ] [ -hheaders ] [ -iflags ] [ -r ] [ -:[i|o]
]
Note: No space is allowed between the option flag and the associated arguments.
1.80.2 Description
sphdistance reads one or more ASCII [or binary] files (or standard input) containing lon, lat and performs the construction of Voronoi polygons. These polygons are then processed to calculate the nearest
distance to each node of the lattice and written to the specified grid. The Voronoi algorithm used is
STRIPACK. As an option, you may provide pre-calculated Voronoi polygon file in the format written by
sphtriangulate, thus bypassing the memory- and time-consuming triangularization.
1.80. sphdistance
303
304
bottom. e.g., BL for lower left. This indicates which point on a rectangular region the lon/lat coordinate refers to, and the grid dimensions nx and ny with grid spacings via -I is used to create
the corresponding region. Alternatively, specify the name of an existing grid file and the -R settings (and grid spacing, if applicable) are copied from the grid. Using -Runit expects projected
(Cartesian) coordinates compatible with chosen -J and we inversely project to determine actual
rectangular geographic region. For perspective view (-p), optionally append /zmin/zmax. In case
of perspective view (-p), a z-range (zmin, zmax) can be appended to indicate the third dimension.
This needs to be done only when using the -Jz option, not when using only the -p option. In the
latter case a perspective view of the plane is plotted, with no third dimension.
-V[level] (more ...) Select verbosity level [c].
-bi[ncols][t] (more ...) Select native binary input. [Default is 2 input columns].
-bo[ncols][type] (more ...) Select native binary output. [Default is same as input].
-d[i|o]nodata (more ...) Replace input columns that equal nodata with NaN and do the reverse on output.
-h[i|o][n][+c][+d][+rremark][+rtitle] (more ...) Skip or produce header record(s).
-icols[l][sscale][ooffset][,...] (more ...) Select input columns (0 is first column).
-r (more ...) Set pixel node registration [gridline].
-:[i|o] (more ...) Swap 1st and 2nd column on input and/or output.
-^ or just - Print a short message about the syntax of the command, then exits (NOTE: on Windows use
just -).
-+ or just + Print an extensive usage (help) message, including the explanation of any module-specific
option (but not the GMT common options), then exits.
-? or no arguments Print a complete usage (help) message, including the explanation of options, then
exits.
1.80. sphdistance
305
1.80.7 Examples
To construct Voronoi polygons from the points in the file testdata.txt and then calculate distances from
the data to a global 1x1 degree grid, use
gmt sphdistance testdata.txt -Rg -I1 -Gglobedist.nc
To generate the same grid in two steps using sphtriangulate separately, try
gmt sphtriangulate testdata.txt -Qv > voronoi.txt
gmt sphdistance -Qvoronoi.txt -Rg -I1 -Gglobedist.nc
1.80.9 References
Renka, R, J., 1997, Algorithm 772: STRIPACK: Delaunay Triangulation and Voronoi Diagram on the
Surface of a Sphere, AMC Trans. Math. Software, 23(3), 416-434.
1.81 sphinterpolate
sphinterpolate - Spherical gridding in tension of data on a sphere
1.81.1 Synopsis
sphinterpolate [ table ] -Ggrdfile [ -Iincrement ] [ -Qmode[/options] ] [ -Rregion ] [ -V[level] ] [ -Z ] [
-bibinary ] [ -dinodata ] [ -hheaders ] [ -iflags ] [ -r ] [ -:[i|o] ]
Note: No space is allowed between the option flag and the associated arguments.
1.81.2 Description
sphinterpolate reads one or more ASCII [or binary] files (or standard input) containing lon, lat, f and
performs a Delaunay triangulation to set up a spherical interpolation in tension. The final grid is saved
to the specified file. Several options may be used to affect the outcome, such as choosing local versus
global gradient estimation or optimize the tension selection to satisfy one of four criteria.
306
1.81. sphinterpolate
307
-bi[ncols][t] (more ...) Select native binary input. [Default is 3 input columns].
-dinodata (more ...) Replace input columns that equal nodata with NaN.
-h[i|o][n][+c][+d][+rremark][+rtitle] (more ...) Skip or produce header record(s).
-:[i|o] (more ...) Swap 1st and 2nd column on input and/or output.
-r (more ...) Set pixel node registration [gridline].
-^ or just - Print a short message about the syntax of the command, then exits (NOTE: on Windows use
just -).
-+ or just + Print an extensive usage (help) message, including the explanation of any module-specific
option (but not the GMT common options), then exits.
-? or no arguments Print a complete usage (help) message, including the explanation of options, then
exits.
1.81.6 Examples
To interpolate the points in the file testdata.txt on a global 1x1 degree grid with no tension, use
sphinterpolate testdata.txt -Rg -I1 -Gsolution.nc
1.81.8 References
Renka, R, J., 1997, Algorithm 772: STRIPACK: Delaunay Triangulation and Voronoi Diagram on the
Surface of a Sphere, AMC Trans. Math. Software, 23(3), 416-434.
Renka, R, J 1997, Algorithm 773: SSRFPACK: Interpolation of scattered data on the Surface of a
Sphere with a surface under tension, AMC Trans. Math. Software, 23(3), 435-442.
1.82 sphtriangulate
sphtriangulate - Delaunay or Voronoi construction of spherical lon,lat data
308
1.82.1 Synopsis
sphtriangulate [ table ] [ -A ] [ -C ] [ -D ] [ -Lunit ] [ -Nnfile ] [ -Qd|v ] [ -T ] [ -V[level] ] [ -bbinary ]
[ -dnodata ] [ -hheaders ] [ -iflags ] [ -:[i|o] ]
Note: No space is allowed between the option flag and the associated arguments.
1.82.2 Description
sphtriangulate reads one or more ASCII [or binary] files (or standard input) containing lon, lat and
performs a spherical Delaunay triangulation, i.e., it find how the points should be connected to give the
most equilateral triangulation possible on the sphere. Optionally, you may choose -Qv which will do
further processing to obtain the Voronoi polygons. Normally, either set of polygons will be written as
fillable segment output; use -T to write unique arcs instead. As an option, compute the area of each
triangle or polygon. The algorithm used is STRIPACK.
1.82. sphtriangulate
309
-bi[ncols][t] (more ...) Select native binary input. [Default is 2 input columns].
-bo[ncols][type] (more ...) Select native binary output. [Default is same as input].
-d[i|o]nodata (more ...) Replace input columns that equal nodata with NaN and do the reverse on output.
-h[i|o][n][+c][+d][+rremark][+rtitle] (more ...) Skip or produce header record(s).
-:[i|o] (more ...) Swap 1st and 2nd column on input and/or output.
-r (more ...) Set pixel node registration [gridline].
-^ or just - Print a short message about the syntax of the command, then exits (NOTE: on Windows use
just -).
-+ or just + Print an extensive usage (help) message, including the explanation of any module-specific
option (but not the GMT common options), then exits.
-? or no arguments Print a complete usage (help) message, including the explanation of options, then
exits.
1.82.6 Examples
To triangulate the points in the file testdata.txt, and make a Voronoi diagram via psxy, use
gmt sphtriangulate testdata.txt -Qv | psxy -Rg -JG30/30/6i -L -P -W1p -B0g30 | gv
-
To compute the optimal Delaunay triangulation network based on the multiple segment file globalnodes.d and save the area of each triangle in the header record, try
gmt sphtriangulate globalnodes.d -Qd -A > global_tri.d
1.82.8 References
Renka, R, J., 1997, Algorithm 772: STRIPACK: Delaunay Triangulation and Voronoi Diagram on the
Surface of a Sphere, AMC Trans. Math. Software, 23(3), 416-434.
310
1.83 splitxyz
splitxyz - Split xyz[dh] data tables into individual segments
1.83.1 Synopsis
splitxyz [ table ] [ -Aazimuth/tolerance ] [ -Ccourse_change] [ -Dminimum_distance ] [ Fxy_filter/z_filter ] [ -Ntemplate ] [ -Qflags ] [ -S ] [ -V[level] ] [ -bbinary ] [ -dnodata ] [ -fflags ]
[ -ggaps ] [ -hheaders ] [ -iflags ] [ -:[i|o] ]
Note: No space is allowed between the option flag and the associated arguments.
1.83.2 Description
splitxyz reads a series of (x,y[,z]) records [or optionally (x,y,z,d,h); see -S option] from standard input
[or xyz[dh]file] and splits this into separate lists of (x,y[,z]) series, such that each series has a nearly
constant azimuth through the x,y plane. There are options to choose only those series which have a
certain orientation, to set a minimum length for series, and to high- or low-pass filter the z values and/or
the x,y values. splitxyz is a useful filter between data extraction and pswiggle plotting, and can also be
used to divide a large x,y[,z] dataset into segments.
1.83. splitxyz
311
-Ntemplate Write each segment to a separate output file [Default writes a multiple segment file to
stdout]. Append a format template for the individual file names; this template must contain a
C format specifier that can format an integer argument (the running segment number across
all tables); this is usually %d but could be %08d which gives leading zeros, etc. [Default is
splitxyz_segment_%d.{txt|bin}, depending on -bo]. Alternatively, give a template with two C
format specifiers and we will supply the table number and the segment number within the table to
build the file name.
-Qflags Specify your desired output using any combination of xyzdh, in any order. Do not space between
the letters. Use lower case. The output will be ASCII (or binary, see -bo) columns of values
corresponding to xyzdh [Default is -Qxyzdh (-Qxydh if only 2 input columns)].
-S Both d and h are supplied. In this case, input contains x,y,z,d,h. [Default expects (x,y,z) input, and
d,h are computed from delta x, delta y. Use -fg to indicate map data; then x,y are assumed to be in
degrees of longitude, latitude, distances are considered to be in kilometers, and angles are actually
azimuths. Otherwise, distances are Cartesian in same units as x,y and angles are counter-clockwise
from horizontal].
-V[level] (more ...) Select verbosity level [c].
-bi[ncols][t] (more ...) Select native binary input. [Default is 2, 3, or 5 input columns as set by -S].
-bo[ncols][type] (more ...) Select native binary output. [Default is 1-5 output columns as set by -Q].
-d[i|o]nodata (more ...) Replace input columns that equal nodata with NaN and do the reverse on output.
-f[i|o]colinfo (more ...) Specify data types of input and/or output columns.
-g[a]x|y|d|X|Y|D|[col]z[+|-]gap[u] (more ...) Determine data gaps and line breaks. Do not let a segment
have a gap exceeding gap; instead, split it into two segments. [Default ignores gaps].
-h[i|o][n][+c][+d][+rremark][+rtitle] (more ...) Skip or produce header record(s).
-icols[l][sscale][ooffset][,...] (more ...) Select input columns (0 is first column).
-:[i|o] (more ...) Swap 1st and 2nd column on input and/or output.
-^ or just - Print a short message about the syntax of the command, then exits (NOTE: on Windows use
just -).
-+ or just + Print an extensive usage (help) message, including the explanation of any module-specific
option (but not the GMT common options), then exits.
-? or no arguments Print a complete usage (help) message, including the explanation of options, then
exits.
312
1.83.7 Examples
Suppose you want to make a wiggle plot of magnetic anomalies on segments oriented approximately
east-west from a NGDC-supplied cruise called JA020015 in the region -R300/315/12/20. You want to
use a 100 km low-pass filter to smooth the tracks and a 500km high-pass filter to detrend the magnetic
anomalies. Try this:
gmt mgd77list JA020015 -R300/315/12/20 -Flon,lat,mag,dist,azim | gmt splitxyz A90/15 -F100/-500 \
-D100 -S -V -fg | gmt pswiggle -R300/315/12/20 -Jm0.6i -Baf -B+tJA020015 -T1 \
-W0.75p -Ggray -Z200 > JA020015_wiggles.ps
MGD-77 users: For this application we recommend that you extract dist,azim from mgd77list rather than
have splitxyz compute them separately.
Suppose you have been given a binary, double-precision file containing lat, lon, gravity values from a
survey, and you want to split it into profiles named survey_###.txt (when gap exceeds 100 km). Try this:
gmt splitxyz survey.bin -Nsurvey_%03d.txt -V -gd100k -D100 -: -fg -bi3d
1.84 surface
surface - Grid table data using adjustable tension continuous curvature splines
1.84.1 Synopsis
surface [ table ] -Goutputfile.nc -Iincrement -Rregion [ -Aaspect_ratio ] [ -Cconvergence_limit[%] ] [
-Lllower ] [ -Luupper ] [ -Nmax_iterations ] [ -Q ] [ -Ssearch_radius[m|s] ] [ -T[i|b]tension_factor ] [
-V[level] ] [ -Zover-relaxation_factor ] [ -aflags ] [ -bibinary ] [ -dinodata ] [ -fflags ] [ -hheaders ] [
-iflags ] [ -r ] [ -:[i|o] ]
Note: No space is allowed between the option flag and the associated arguments.
1.84.2 Description
surface reads randomly-spaced (x,y,z) triples from standard input [or table] and produces a binary grid
file of gridded values z(x,y) by solving:
(1 - T) * L (L (z)) + T * L (z) = 0
1.84. surface
313
where T is a tension factor between 0 and 1, and L indicates the Laplacian operator. T = 0 gives the
minimum curvature solution which is equivalent to SuperMISP and the ISM packages. Minimum
curvature can cause undesired oscillations and false local maxima or minima (See Smith and Wessel,
1990), and you may wish to use T > 0 to suppress these effects. Experience suggests T ~ 0.25 usually
looks good for potential field data and T should be larger (T ~ 0.35) for steep topography data. T = 1 gives
a harmonic surface (no maxima or minima are possible except at control data points). It is recommended
that the user pre-process the data with blockmean, blockmedian, or blockmode to avoid spatial aliasing
and eliminate redundant data. You may impose lower and/or upper bounds on the solution. These may be
entered in the form of a fixed value, a grid with values, or simply be the minimum/maximum input data
values. Natural boundary conditions are applied at the edges, except for geographic data with 360-degree
range where we apply periodic boundary conditions in the longitude direction.
314
or u for unconstrained [Default]. uupper sets the upper bound and can be the name of a grid file
with upper bound values, a fixed value, d to set to maximum input value, or u for unconstrained
[Default]. Grid files used to set the limits may contain NaNs. In the presence of NaNs, the limit of
a node masked with NaN is unconstrained.
-Nmax_iterations Number of iterations. Iteration will cease when convergence_limit is reached or when
number of iterations reaches max_iterations. This is the final iteration limit at the desired grid
spacing; for intermediate (coarser) grids the effective iteration limit is scaled by the grid spacing
multiplier. [Default is 500.]
-Q Suggest grid dimensions which have a highly composite greatest common factor. This allows surface
to use several intermediate steps in the solution, yielding faster run times and better results. The
sizes suggested by -Q can be achieved by altering -R and/or -I. You can recover the -R and -I you
want later by using grdsample or grdcut on the output of surface.
-Ssearch_radius[m|s] Search radius. Enter search_radius in same units as x,y data; append m to indicate arc minutes or s for arc seconds. This is used to initialize the grid before the first iteration; it
is not worth the time unless the grid lattice is prime and cannot have regional stages. [Default =
0.0 and no search is made.]
-T[i|b]tension_factor Tension factor[s]. These must be between 0 and 1. Tension may be used in the
interior solution (above equation, where it suppresses spurious oscillations) and in the boundary
conditions (where it tends to flatten the solution approaching the edges). Using zero for both
values results in a minimum curvature surface with free edges, i.e., a natural bicubic spline. Use
-Titension_factor to set interior tension, and -Tbtension_factor to set boundary tension. If you
do not prepend i or b, both will be set to the same value. [Default = 0 for both gives minimum
curvature solution.]
-V[level] (more ...) Select verbosity level [c]. -V3 will report the convergence after each iteration; -V
will report only after each regional grid is converged.
-Zover-relaxation_factor Over-relaxation factor. This parameter is used to accelerate the convergence;
it is a number between 1 and 2. A value of 1 iterates the equations exactly, and will always assure
stable convergence. Larger values overestimate the incremental changes during convergence, and
will reach a solution more rapidly but may become unstable. If you use a large value for this factor,
it is a good idea to monitor each iteration with the -Vl option. [Default = 1.4 converges quickly
and is almost always stable.]
-acol=name[...] (more ...) Set aspatial column associations col=name.
-bi[ncols][t] (more ...) Select native binary input. [Default is 3 input columns].
-dinodata (more ...) Replace input columns that equal nodata with NaN.
-f[i|o]colinfo (more ...) Specify data types of input and/or output columns.
-h[i|o][n][+c][+d][+rremark][+rtitle] (more ...) Skip or produce header record(s). Not used with binary
data.
-icols[l][sscale][ooffset][,...] (more ...) Select input columns (0 is first column).
-r (more ...) Set pixel node registration [gridline].
-:[i|o] (more ...) Swap 1st and 2nd column on input and/or output.
-^ or just - Print a short message about the syntax of the command, then exits (NOTE: on Windows use
just -).
1.84. surface
315
-+ or just + Print an extensive usage (help) message, including the explanation of any module-specific
option (but not the GMT common options), then exits.
-? or no arguments Print a complete usage (help) message, including the explanation of options, then
exits.
1.84.6 Examples
To grid 5 by 5 minute gravity block means from the ASCII data in hawaii_5x5.xyg, using a tension_factor = 0.25, a convergence_limit = 0.1 milligal, writing the result to a file called hawaii_grd.nc,
and monitoring each iteration, try:
gmt surface hawaii_5x5.xyg -R198/208/18/25 -I5m -Ghawaii_grd.nc -T0.25 -C0.1 -Vl
1.84.7 Bugs
surface will complain when more than one data point is found for any node and suggest that you run
blockmean, blockmedian, or blockmode first. If you did run blockm* and still get this message it
usually means that your grid spacing is so small that you need more decimals in the output format used
by blockm*. You may specify more decimal places by editing the parameter FORMAT_FLOAT_OUT
in your gmt.conf file prior to running blockm*, or choose binary input and/or output using single or
double precision storage.
Note that only gridline registration is possible with surface. If you need a pixel-registered grid you can
resample a gridline registered grid using grdsample -T.
1.84.9 References
Smith, W. H. F, and P. Wessel, 1990, Gridding with continuous curvature splines in tension, Geophysics,
55, 293-305.
1.85 trend1d
trend1d - Fit a [weighted] [robust] polynomial [or Fourier] model for y = f(x) to xy[w] data
316
1.85.1 Synopsis
trend1d [ table ] -Fxymrw|p|P|c -N[p|P|f|F|c|C|s|S|x]n[,...][+llength][+oorigin][+r] [ xy[w]file ] [ Ccondition_number ] [ -I[confidence_level] ] [ -V[level] ] [ -W ] [ -bbinary ] [ -dnodata ] [ -fflags ]
[ -hheaders ] [ -iflags ] [ -:[i|o] ]
Note: No space is allowed between the option flag and the associated arguments.
1.85.2 Description
trend1d reads x,y [and w] values from the first two [three] columns on standard input [or file] and fits a
regression model y = f(x) + e by [weighted] least squares. The functional form of f(x) may be chosen as
polynomial or Fourier or a mix of the two, and the fit may be made robust by iterative reweighting of the
data. The user may also search for the number of terms in f(x) which significantly reduce the variance
in y.
1.85. trend1d
317
confidence level of 0.51. Or choose your own level between 0 and 1. See remarks section. Note
that the model terms are added in the order they were given in -N so you should place the most
important terms first.
-V[level] (more ...) Select verbosity level [c].
-W Weights are supplied in input column 3. Do a weighted least squares fit [or start with these weights
when doing the iterative robust fit]. [Default reads only the first 2 columns.]
-bi[ncols][t] (more ...) Select native binary input. [Default is 2 (or 3 if -W is set) columns].
-bo[ncols][type] (more ...) Select native binary output. [Default is 1-5 columns as given by -F].
-d[i|o]nodata (more ...) Replace input columns that equal nodata with NaN and do the reverse on output.
-f[i|o]colinfo (more ...) Specify data types of input and/or output columns.
-h[i|o][n][+c][+d][+rremark][+rtitle] (more ...) Skip or produce header record(s).
-icols[l][sscale][ooffset][,...] (more ...) Select input columns (0 is first column).
-:[i|o] (more ...) Swap 1st and 2nd column on input and/or output.
-^ or just - Print a short message about the syntax of the command, then exits (NOTE: on Windows use
just -).
-+ or just + Print an extensive usage (help) message, including the explanation of any module-specific
option (but not the GMT common options), then exits.
-? or no arguments Print a complete usage (help) message, including the explanation of options, then
exits.
1.85.6 Remarks
If a polynomial model is included, then the domain of x will be shifted and scaled to [-1, 1] and the
basis functions will be Chebyshev polynomials provided the polygon is of full order (otherwise we
stay with powers of x). The Chebyshev polynomials have a numerical advantage in the form of the
matrix which must be inverted and allow more accurate solutions. The Chebyshev polynomial of degree
n has n+1 extrema in [-1, 1], at all of which its value is either -1 or +1. Therefore the magnitude of
the polynomial model coefficients can be directly compared. NOTE: The stable model coefficients are
Chebyshev coefficients. The corresponding polynomial coefficients in a + bx + cxx + ... are also given
in Verbose mode but users must realize that they are NOT stable beyond degree 7 or 8. See Numerical
Recipes for more discussion. For evaluating Chebyshev polynomials, see gmtmath.
The -N...+r (robust) and -I (iterative) options evaluate the significance of the improvement in model
misfit Chi-Squared by an F test. The default confidence limit is set at 0.51; it can be changed with the
318
-I option. The user may be surprised to find that in most cases the reduction in variance achieved by
increasing the number of terms in a model is not significant at a very high degree of confidence. For
example, with 120 degrees of freedom, Chi-Squared must decrease by 26% or more to be significant
at the 95% confidence level. If you want to keep iterating as long as Chi-Squared is decreasing, set
confidence_level to zero.
A low confidence limit (such as the default value of 0.51) is needed to make the robust method work.
This method iteratively reweights the data to reduce the influence of outliers. The weight is based on
the Median Absolute Deviation and a formula from Huber [1964], and is 95% efficient when the model
residuals have an outlier-free normal distribution. This means that the influence of outliers is reduced
only slightly at each iteration; consequently the reduction in Chi-Squared is not very significant. If the
procedure needs a few iterations to successfully attenuate their effect, the significance level of the F test
must be kept low.
1.85.7 Examples
To remove a linear trend from data.xy by ordinary least squares, use:
gmt trend1d data.xy -Fxr -Np1 > detrended_data.xy
To make the above linear trend robust with respect to outliers, use:
gmt trend1d data.xy -Fxr -Np1+r > detrended_data.xy
To fit the model y(x) = a + bx^2 + c * cos(2*pi*3*(x/l) + d * sin(2*pi*3*(x/l), with l the fundamental
period (here l = 15), try:
gmt trend1d data.xy -Fxm -NP0,P2,F3+l15 > model.xy
To find out how many terms (up to 20, say in a robust Fourier interpolant are significant in fitting data.xy,
use:
gmt trend1d data.xy -Nf20+r -I -V
1.85.9 References
Huber, P. J., 1964, Robust estimation of a location parameter, Ann. Math. Stat., 35, 73-101.
Menke, W., 1989, Geophysical Data Analysis: Discrete Inverse Theory, Revised Edition, Academic
Press, San Diego.
1.86 trend2d
trend2d - Fit a [weighted] [robust] polynomial model for z = f(x,y) to xyz[w] data
1.86. trend2d
319
1.86.1 Synopsis
trend2d [ table ] -Fxyzmrw -Nn_model[r] [ xyz[w]file ] [ -Ccondition_number ] [ -I[confidence_level]
] [ -V[level] ] [ -W ] [ [ -bbinary ] [ -dnodata ] [ -fflags ] [ -hheaders ] [ -iflags ] [ -:[i|o] ]
Note: No space is allowed between the option flag and the associated arguments.
1.86.2 Description
trend2d reads x,y,z [and w] values from the first three [four] columns on standard input [or xyz[w]file]
and fits a regression model z = f(x,y) + e by [weighted] least squares. The fit may be made robust by
iterative reweighting of the data. The user may also search for the number of terms in f(x,y) which
significantly reduce the variance in z. n_model may be in [1,10] to fit a model of the following form
(similar to grdtrend):
m1 + m2*x + m3*y + m4*x*y + m5*x*x + m6*y*y + m7*x*x*x + m8*x*x*y + m9*x*y*y
+ m10*y*y*y.
The user must specify -Nn_model, the number of model parameters to use; thus, -N4 fits a bilinear trend,
-N6 a quadratic surface, and so on. Optionally, append r to perform a robust fit. In this case, the program
will iteratively reweight the data based on a robust scale estimate, in order to converge to a solution
insensitive to outliers. This may be handy when separating a regional field from a residual which
should have non-zero mean, such as a local mountain on a regional surface.
-bo[ncols][type] (more ...) Select native binary output. [Default is 1-6 columns as set by -F].
-d[i|o]nodata (more ...) Replace input columns that equal nodata with NaN and do the reverse on output.
-f[i|o]colinfo (more ...) Specify data types of input and/or output columns.
-h[i|o][n][+c][+d][+rremark][+rtitle] (more ...) Skip or produce header record(s).
-icols[l][sscale][ooffset][,...] (more ...) Select input columns (0 is first column).
-:[i|o] (more ...) Swap 1st and 2nd column on input and/or output.
-^ or just - Print a short message about the syntax of the command, then exits (NOTE: on Windows use
just -).
-+ or just + Print an extensive usage (help) message, including the explanation of any module-specific
option (but not the GMT common options), then exits.
-? or no arguments Print a complete usage (help) message, including the explanation of options, then
exits.
1.86.5 Remarks
The domain of x and y will be shifted and scaled to [-1, 1] and the basis functions are built from
Chebyshev polynomials. These have a numerical advantage in the form of the matrix which must be
inverted and allow more accurate solutions. In many applications of trend2d the user has data located
approximately along a line in the x,y plane which makes an angle with the x axis (such as data collected
along a road or ship track). In this case the accuracy could be improved by a rotation of the x,y axes.
trend2d does not search for such a rotation; instead, it may find that the matrix problem has deficient
rank. However, the solution is computed using the generalized inverse and should still work out OK. The
user should check the results graphically if trend2d shows deficient rank. NOTE: The model parameters
listed with -V are Chebyshev coefficients; they are not numerically equivalent to the m#s in the equation
described above. The description above is to allow the user to match -N with the order of the polynomial
surface. For evaluating Chebyshev polynomials, see grdmath.
The -Nn_modelr (robust) and -I (iterative) options evaluate the significance of the improvement in model
misfit Chi-Squared by an F test. The default confidence limit is set at 0.51; it can be changed with the
-I option. The user may be surprised to find that in most cases the reduction in variance achieved by
increasing the number of terms in a model is not significant at a very high degree of confidence. For
example, with 120 degrees of freedom, Chi-Squared must decrease by 26% or more to be significant
at the 95% confidence level. If you want to keep iterating as long as Chi-Squared is decreasing, set
confidence_level to zero.
A low confidence limit (such as the default value of 0.51) is needed to make the robust method work.
This method iteratively reweights the data to reduce the influence of outliers. The weight is based on
the Median Absolute Deviation and a formula from Huber [1964], and is 95% efficient when the model
residuals have an outlier-free normal distribution. This means that the influence of outliers is reduced
only slightly at each iteration; consequently the reduction in Chi-Squared is not very significant. If the
procedure needs a few iterations to successfully attenuate their effect, the significance level of the F test
must be kept low.
1.86. trend2d
321
1.86.7 Examples
To remove a planar trend from data.xyz by ordinary least squares, use:
gmt trend2d data.xyz -Fxyr -N2 > detrended_data.xyz
To make the above planar trend robust with respect to outliers, use:
gmt trend2d data.xzy -Fxyr -N2r > detrended_data.xyz
To find out how many terms (up to 10 in a robust interpolant are significant in fitting data.xyz, use:
gmt trend2d data.xyz -N10r -I -V
1.86.9 References
Huber, P. J., 1964, Robust estimation of a location parameter, Ann. Math. Stat., 35, 73-101.
Menke, W., 1989, Geophysical Data Analysis: Discrete Inverse Theory, Revised Edition, Academic
Press, San Diego.
1.87 triangulate
triangulate - Optimal (Delaunay) triangulation and gridding of Cartesian table data
1.87.1 Synopsis
triangulate [ table ] [ -Dx|y ] [ -Eempty ] [ -Ggrdfile ] [ -Iincrement ] [ -Jparameters ] [ -M ] [ -N ] [ -Q
] [ -Rregion ] [ -S ] [ -V[level] ] [ -Z ] [ -bbinary ] [ -dnodata ] [ -fflags ] [ -hheaders ] [ -iflags ] [ -r ] [
-:[i|o] ]
Note: No space is allowed between the option flag and the associated arguments.
322
1.87.2 Description
triangulate reads one or more ASCII [or binary] files (or standard input) containing x,y[,z] and performs
Delaunay triangulation, i.e., it find how the points should be connected to give the most equilateral triangulation possible. If a map projection (give -R and -J) is chosen then it is applied before the triangulation
is calculated. By default, the output is triplets of point id numbers that make up each triangle and is written to standard output. The id numbers refer to the points position (line number, starting at 0 for the first
line) in the input file. As an option, you may choose to create a multiple segment file that can be piped
through psxy to draw the triangulation network. If -G -I are set a grid will be calculated based on the
surface defined by the planar triangles. The actual algorithm used in the triangulations is either that of
Watson [1982] [Default] or Shewchuk [1996] (if installed; type triangulate - to see which method is
selected). This choice is made during the GMT installation.
1.87. triangulate
323
-bo[ncols][type] (more ...) Select native binary output. [Default is same as input]. Node ids are stored
as double triplets.
-d[i|o]nodata (more ...) Replace input columns that equal nodata with NaN and do the reverse on output.
-f[i|o]colinfo (more ...) Specify data types of input and/or output columns.
-h[i|o][n][+c][+d][+rremark][+rtitle] (more ...) Skip or produce header record(s).
-icols[l][sscale][ooffset][,...] (more ...) Select input columns (0 is first column).
-r (more ...) Set pixel node registration [gridline]. (Only valid with -G).
-:[i|o] (more ...) Swap 1st and 2nd column on input and/or output.
-^ or just - Print a short message about the syntax of the command, then exits (NOTE: on Windows use
just -).
-+ or just + Print an extensive usage (help) message, including the explanation of any module-specific
option (but not the GMT common options), then exits.
-? or no arguments Print a complete usage (help) message, including the explanation of options, then
exits.
1.87.7 Examples
To triangulate the points in the file samples.xyz, store the triangle information in a binary file, and make
a grid for the given area and spacing, use
gmt triangulate samples.xyz -bo -R0/30/0/30 -I2 -Gsurf.nc > samples.ijk
To draw the optimal Delaunay triangulation network based on the same file using a 15-cm-wide Mercator
map, use
324
1.87.9 References
Watson, D. F., 1982, Acord: Automatic contouring of raw data, Comp. & Geosci., 8, 97-101.
Shewchuk, J. R., 1996, Triangle: Engineering a 2D Quality Mesh Generator and Delaunay Triangulator,
First Workshop on Applied Computational Geometry (Philadelphia, PA), 124-133, ACM, May 1996.
Shewchuks Homepage
1.88 xyz2grd
xyz2grd - Convert data table to a grid file
1.88.1 Synopsis
xyz2grd [ table ] -Ggrdfile -Iincrement -Rregion [ -A[f|l|m|n|r|s|u|z] ] [ Dxname/yname/zname/scale/offset/invalid/title/remark ] [ -S[zfile] ] [ -V[level] ] [ -Z[flags] ] [
-bibinary ] [ -dinodata ] [ -fflags ] [ -hheaders ] [ -iflags ] [ -r ] [ -:[i|o] ]
Note: No space is allowed between the option flag and the associated arguments.
1.88.2 Description
xyz2grd reads one or more z or xyz tables and creates a binary grid file. xyz2grd will report if some of
the nodes are not filled in with data. Such unconstrained nodes are set to a value specified by the user
[Default is NaN]. Nodes with more than one value will be set to the mean value. As an option (using
-Z), a 1-column z-table may be read assuming all nodes are present (z-tables can be in organized in a
number of formats, see -Z below.)
325
and will be converted to the equivalent degrees longitude at the middle latitude of the region (the
conversion depends on PROJ_ELLIPSOID). If y_inc is given but set to 0 it will be reset equal to
x_inc; otherwise it will be converted to degrees latitude. All coordinates: If = is appended then the
corresponding max x (east) or y (north) may be slightly adjusted to fit exactly the given increment
[by default the increment may be adjusted slightly to fit the given domain]. Finally, instead of
giving an increment you may specify the number of nodes desired by appending + to the supplied
integer argument; the increment is then recalculated from the number of nodes and the domain.
The resulting increment value depends on whether you have selected a gridline-registered or pixelregistered grid; see App-file-formats for details. Note: if -Rgrdfile is used then the grid spacing
has already been initialized; use -I to override the values.
-R[unit]xmin/xmax/ymin/ymax[r] (more ...) Specify the region of interest.
1.88. xyz2grd
327
1.88.9 Examples
To create a grid file from the ASCII data in hawaii_grv.xyz, use
gmt xyz2grd hawaii_grv.xyz -Ddegree/degree/mGal/1/0//Hawaiian Gravity/GRS-80 Ellipsoid used
-Ghawaii_grv_new.nc -R198/208/18/25 -I5m -V
To create a grid file from the raw binary (3-column, single-precision scanline-oriented data raw.b, use
gmt xyz2grd raw.b -Dm/m/m/1/0 -Graw.nc -R0/100/0/100 -I1 -V -Z -bi3f
To make a grid file from the raw binary USGS DEM (short integer scanline-oriented data topo30.b on
the NGDC global relief Data CD-ROM, with values of -9999 indicate missing data, one must on some
machine reverse the byte-order. On such machines (like Sun), use
gmt xyz2grd topo30.b -Dm/m/m/1/0 -Gustopo.nc -R234/294/24/50 -I30s -di-9999 -ZTLhw
Say you have received a binary file with 4-byte floating points that were written on a machine of different
byte-order than yours. You can swap the byte-order with
gmt xyz2grd floats.bin -Snew_floats.bin -V -Zf
328
1.88. xyz2grd
329
330
CHAPTER 2
Supplementary modules
2.1 gshhg
gshhg - Extract data tables from binary GSHHG or WDBII data files
2.1.1 Synopsis
gshhg binaryfile.b [ -Amin ] [ -G ] [ -Iid ] [ -L ] [ -Nlevel ] [ -Qe|i ] [ -bobinary ] [ -donodata ] [ -oflags
]
Note: No space is allowed between the option flag and the associated arguments.
2.1.2 Description
gshhg reads the binary coastline (GSHHG) or political boundary or river (WDBII) files and writes an
ASCII (or binary; see -b) listing to standard output. It automatically handles byte-swabbing between
different architectures. Optionally, only segment header info can be displayed. The header info has the
format ID npoints hierarchical-level source area f_area west east south north container ancestor, where
hierarchical levels for coastline polygons go from 1 (shoreline) to 4 (lake inside island inside lake inside
land). Source is either W (World Vector Shoreline) or C (CIA World Data Bank II); lower case is used
if a lake is a river-lake. The west east south north is the enclosing rectangle, area is the polygon area
in km^2 while f_area is the actual area of the ancestor polygon, container is the ID of the polygon that
contains this polygon (-1 if none), and ancestor is the ID of the polygon in the full resolution set that was
reduced to yield this polygon (-1 if full resolution since there is no ancestor). For line data the header is
simply ID npoints hierarchical-level source west east south north. For more information about the file
formats, see TECHNICAL INFORMATION below.
331
-G Write output that can be imported into GNU Octave or Matlab by ending segments with a NaNrecord.
-Iid Only output information for the polygon that matches id. Use -Ic to get all the continents only
[Default outputs all polygons]. See below for the id of the largest polygons.
-L Only output a listing of polygon or line segment headers [Default outputs headers and data records].
-N Only output features whose level matches the given level [Default will output all levels].
-Qe|i Control what to do with river-lakes (river sections large enough to be stored as closed polygons).
Use -Qe to exclude them and -Qi to exclude everything else instead [Default outputs all polygons].
-bo[ncols][type] (more ...) Select native binary output.
-donodata (more ...) Replace output columns that equal NaN with nodata.
-ocols[,...] (more ...) Select output columns (0 is first column).
2.1.5 Examples
To convert the entire intermediate GSHHG binary data to ASCII files for Octave/Matlab, run
gmt gshhg gshhs_i.b --IO_SEGMENT_MARKER=N > gshhs_i.txt
To only get a listing of the headers for the river data set at full resolution, try
gmt gshhg wdb_rivers_f.b -L > riverlisting.txt
To only extract lakes, excluding river-lakes, from the high resolution file, try
gmt gshhg gshhs_h.b -Ee -N2 > all_lakes.txt
332
2.1.8 References
Douglas, D. H., and T. K. Peucker, 1973, Algorithms for the reduction of the number of points required
to represent a digitized line of its caricature, Can. Cartogr., 10, 112-122.
Gorny, A. J., 1977, World Data Bank II General User GuideRep. PB 271869, 10pp, Central Intelligence
Agency, Washington, DC.
Soluri, E. A., and V. A. Woodson, 1990, World Vector Shoreline, Int. Hydrograph. Rev., LXVII(1), 27-35.
Wessel, P., and W. H. F. Smith, 1996, A global, self-consistent, hierarchical, high-resolution shoreline
database, J. Geophys. Res., 101(B4), 8741-8743.*
2.1. gshhg
333
2.2 img2grd
img2grd - Extract subset of img file in Mercator or Geographic format
2.2.1 Synopsis
img2grd imgfile -Ggrdfile -Rregion -Ttype [ -C ] [ -D[minlat/maxlat] ] [ -E ] [ -Iminutes ] [ -M ] [
-Nnavg ] [ -S[scale] ] [ -V[level] ] [ -Wmaxlon ] [ -nflags ]
Note: No space is allowed between the option flag and the associated arguments.
2.2.2 Description
img2grd reads an img format file, extracts a subset, and writes it to a grid file. The -M option dictates
whether or not the Spherical Mercator projection of the img file is preserved or if a Geographic grid
should be written by undoing the Mercator projection. If geographic grid is selected you can also request
a resampling onto the exact -R given.
334
-D[minlat/maxlat] Use the extended latitude range -80.738/+80.738. Alternatively, append minlat/maxlat as the latitude extent of the input img file. [Default is -72.006/72.006]. Not usually
required since we can determine the extent from inspection of the file size.
-E Can be used when -M is not set to force the final grid to have the exact same region as requested
with -R. By default, the final region is a direct projection of the original Mercator region and will
typically extend slightly beyond the requested latitude range, and furthermore the grid increment
in latitude does not match the longitude increment. However, the extra resampling introduces
small interpolation errors and should only be used if the output grid must match the requested
region and have x_inc = y_inc. In this case the region set by -R must be given in multiples of the
increment (.e.g, -R0/45/45/72).
-I Indicate minutes as the width of an input img pixel in minutes of longitude. [Default is 2.0]. Not
usually required since we can determine the pixel size from inspection of the size.
-M Output a Spherical Mercator grid [Default is a geographic lon/lat grid]. The Spherical Mercator
projection of the img file is preserved, so that the region -R set by the user is modified slightly;
the modified region corresponds to the edges of pixels [or groups of navg pixels]. The grid file
header is set so that the x and y axis lengths represent distance from the west and south edges of
the image, measured in user default units, with -Jm1 and the adjusted -R. By setting the default
PROJ_ ELLIPSOID = Sphere, the user can make overlays with the adjusted -R so that they
match. See EXAMPLES below. The adjusted -R is also written in the grid header remark, so it
can be found later. See -C to set coordinates relative to projection center.
-Nnavg Average the values in the input img pixels into navg by navg squares, and create one output
pixel for each such square. If used with -T3 it will report an average constraint between 0 and
1. If used with -T2 the output will be average data value or NaN according to whether average
constraint is > 0.5. navg must evenly divide into the dimensions of the imgfile in pixels. [Default
1 does no averaging].
-S[scale] Multiply the img file values by scale before storing in grid file. [Default is 1.0]. For recent img
files: img topo files are stored in (corrected) meters [-S1]; free-air gravity files in mGal*10 [-S0.1
to get mGal]; vertical deflection files in micro-radians*10 [-S0.1 to get micro-radians], vertical
gravity gradient files in Eotvos*50 [-S0.02 to get Eotvos, or -S0.002 to get mGal/km]). If no scale
is given we try to determine the scale by examining the file name for clues.
-Ttype type handles the encoding of constraint information. type = 0 indicates that no such information
is encoded in the img file (used for pre-1995 versions of the gravity data) and gets all data. type
> 0 indicates that constraint information is encoded (1995 and later (current) versions of the img
files) so that one may produce a grid file as follows: -T1 gets data values at all points, -T2 gets
data values at constrained points and NaN at interpolated points; -T3 gets 1 at constrained points
and 0 at interpolated points [Default is 1].
-V[level] (more ...) Select verbosity level [c]. Particularly recommended here, as it is helpful to see how
the coordinates are adjusted.
-Wmaxlon Indicate maxlon as the maximum longitude extent of the input img file. Versions since 1995
have had maxlon = 360.0, while some earlier files had maxlon = 390.0. [Default is 360.0].
-^ or just - Print a short message about the syntax of the command, then exits (NOTE: on Windows use
just -).
-+ or just + Print an extensive usage (help) message, including the explanation of any module-specific
option (but not the GMT common options), then exits.
-? or no arguments Print a complete usage (help) message, including the explanation of options, then
exits.
2.2. img2grd
335
Because the latitude spacing in the img file is equidistant in Mercator units, the resulting grid will not
match the specified -R exactly, and the latitude spacing will not equal the longitude spacing. If you need
an exact match with your -R and the same spacing in longitude and latitude, use the -E option:
img2grd world_grav.img.16.1 -Gmerc_grav.nc -R-40/40/-70/-30 -E -V
Note that the -V option tells us that the range was adjusted to -R-40/40/-70.0004681551/29.9945810754. We can also use grdinfo to find that the grid file header shows its region to be R0/80/0/67.9666667 This is the range of x,y we will get from a Spherical Mercator projection using
-R-40/40/-70.0004681551/-29.9945810754 and -Jm1. Thus, to take ship.lonlatgrav and use it to sample
the merc_grav.nc, we can do this:
gmt set PROJ_ELLIPSOID Sphere
gmt mapproject -R-40/40/-70.0004681551/-29.9945810754 -Jm1i ship.lonlatgrav | \
gmt grdtrack -Gmerc_grav.nc | gmt mapproject \
-R-40/40/-70.0004681551/-29.9945810754 -Jm1i -I > ship.lonlatgravsat
It is recommended to use the above method of projecting and unprojecting the data in such an application, because then there is only one interpolation step (in grdtrack). If one first tries to convert the grid
file to lon,lat and then sample it, there are two interpolation steps (in conversion and in sampling).
To make a lon,lat grid from the above grid we can use
gmt grdproject merc_grav.nc -R-40/40/-70.0004681551/-29.9945810754 -Jm1i -I -D2m Ggrav.nc
In some cases this will not be easy as the -R in the two coordinate systems may not align well. When
this happens, we can also use (in fact, it may be always better to use)
gmt grd2xyz merc_grav.nc | gmt mapproject \
-R-40/40/-70.0004681551/-29.994581075 -Jm1i -I | \
gmt surface -R-40/40/-70/70 -I2m -Ggrav.nc
To make a Mercator map of the above region, suppose our gmt.conf value for PROJ_LENGTH_UNIT
is inch. Then since the above merc_grav.nc file is projected with -Jm1i it is 80 inches wide. We can
make a map 8 inches wide by using -Jx0.1i on any map programs applied to this grid (e.g., grdcontour,
336
grdimage, grdview), and then for overlays which work in lon,lat (e.g., psxy, pscoast) we can use the
above adjusted -R and -Jm0.1 to get the two systems to match up.
However, we can be smarter than this. Realizing that the input img file had pixels 2.0 minutes wide (or
checking the nx and ny with grdinfo merc_grav.nc) we realize that merc_grav.nc used the full resolution
of the img file and it has 2400 by 2039 pixels, and at 8 inches wide this is 300 pixels per inch. We decide
we do not need that many and we will be satisfied with 100 pixels per inch, so we want to average
the data into 3 by 3 squares. (If we want a contour plot we will probably choose to average the data
much more (e.g., 6 by 6) to get smooth contours.) Since 2039 isnt divisible by 3 we will get a different
adjusted -R this time:
gmt img2grd -M world_grav.img.7.2 -Gmerc_grav_2.nc -R-40/40/-70/-30 -N3 -V
This time we find the adjusted region is -R-40/40/-70.023256525/-29.9368261101 and the output is
800 by 601 pixels, a better size for us. Now we can create an artificial illumination file for this using
grdgradient:
gmt grdgradient merc_grav_2.nc -Gillum.nc -A0/270 -Ne0.6
and if we also have a CPT called grav.cpt we can create a color shaded relief map like this:
gmt grdimage merc_grav_2.nc -Iillum.nc -Cgrav.cpt -Jx0.1i -K > map.ps
gmt psbasemap -R-40/40/-70.023256525/-29.9368261101 -Jm0.1i -Ba10 -O >> map.ps
Suppose you want to obtain only the constrained data values from an img file, in lat/lon coordinates.
Then run img2grd with the -T2 option, use grd2xyz to dump the values, pipe through grep -v NaN to
eliminate NaNs, and pipe through mapproject with the inverse projection as above.
2.3 pscoupe
pscoupe - Plot cross-sections of focal mechanisms
2.3.1 Synopsis
pscoupe [ files ] -Jparameters -Rregion -Aparameters [ -B[p|s]parameters ] [ -Ecolor ] [ -Fmode[args]
] [ -Gcolor ] [ -K ] [ -L[pen] ] [ -M ] [ -N ] [ -O ] [ -Q ] [ -S<symbol><scale>[/d] ] [ -Tn ] [ -U[stamp]
] [ -V[level] ] [ -Wpen ] [ -Xx_offset ] [ -Yy_offset ] [ -Zcpt ] [ -ccopies ] [ -dinodata ] [ -hheaders ] [
-iflags ] [ -ttransp ] [ -:[i|o] ]
Note: No space is allowed between the option flag and the associated arguments.
2.3.2 Description
pscoupe reads data values from files [or standard input] and generates PostScript code that will plot
symbols, lines or polygons on a cross-section. Focal mechanisms may be specified and require additional
columns of data. The PostScript code is written to standard output.
2.3. pscoupe
337
Unless -Q is used, new file is created with the new coordinates (x, y) and the mechanism (from lower
focal half-sphere for horizontal plane, to half-sphere behind a vertical plane). When the plane is not
horizontal, - north direction becomes upwards steepest descent direction of the plane (u) - east direction
becomes strike direction of the plane (s) - down direction (= north^east) becomes u^s Axis angles are
defined in the same way as in horizontal plane in the new system. Moment tensor (initially in r, t, f
system that is up, south, east) is defined in (-u^s, -u, s) system.
339
9,10: not used; can be 0 0; allows use of the psmeca file format
11: text string to appear above the beach ball (default) or under (add u).
-Sm|d|zscale[/fontsize[/offset[u]]] Seismic moment tensor (Harvard CMT, with zero trace). scale
adjusts the scaling of the radius of the beach ball, which will be proportional to the magnitude. The scale is the size for magnitude = 5 (that is seismic scalar moment = 4E+23
dynes-cm) in PROJ_LENGTH_UNIT (unless c, i, or p is appended to indicate that the size
information is in units of cm, inches, meters, or points, respectively). (-T0 option overlays
best double couple transparently.)
-Sdscale[/fontsize[/offset[u]]] to plot the only double couple part of moment tensor.
-Szscale[/fontsize[/offset[u]]] to plot anisotropic part of moment tensor (zero trace). The color or
shade of the compressive quadrants can be specified with the -G option. The color or shade
of the extensive quadrants can be specified with the -E option. Parameters are expected to be
in the following columns:
1,2: longitude, latitude of event (-: option interchanges order)
3: depth of event in kilometers
4,5,6,7,8,9: mrr, mtt, mff, mrt, mrf, mtf in 10*exponent dynes-cm
10: exponent
11,12: Not used; can be 0 0; allows use of the psmeca file format
13: Text string to appear above the beach ball (default) or under (add u).
-Sxscale[/fontsize[/offset[u]]] Principal axis. scale adjusts the scaling of the radius of the beach
ball, which will be proportional to the magnitude. The scale is the size for magnitude = 5
(that is seismic scalar moment = 4*10e+23 dynes-cm) in PROJ_LENGTH_UNIT (unless
c, i, or p is appended to indicate that the size information is in units of cm, inches, meters,
or points, respectively). (-T0 option overlays best double couple transparently.)
-Syscale[/fontsize[/offset[u]]] to plot the only double couple part of moment tensor.
-Stscale[/fontsize[/offset[u]]] to plot anisotropic part of moment tensor (zero trace). The color or
shade of the compressive quadrants can be specified with the -G option. The color or shade
of the extensive quadrants can be specified with the -E option. Parameters are expected to be
in the following columns:
1,2: longitude, latitude of event (-: option interchanges order)
3: depth of event in kilometers
4,5,6,7,8,9,10,11,12: value (in 10*exponent dynes-cm), azimuth, plunge of the T,
N, and P axes.
13: exponent
14,15: longitude, latitude at which to place beach ball. Entries in these columns
are necessary with the -C option. Using 0,0 in columns 9 and 10 will plot the
beach ball at the longitude, latitude given in columns 1 and 2. The -: option
will interchange the order of columns (1,2) and (9,10).
16: Text string to appear above the beach ball (optional).
340
2.3. pscoupe
341
-Zcpt Give a CPT and let compressive part color be determined by the z-value in the third column.
-ccopies (more ...) Specify number of plot copies [Default is 1].
-dinodata (more ...) Replace input columns that equal nodata with NaN.
-h[i|o][n][+c][+d][+rremark][+rtitle] (more ...) Skip or produce header record(s).
-icols[l][sscale][ooffset][,...] (more ...) Select input columns (0 is first column).
-t[transp] (more ...) Set PDF transparency level in percent.
-:[i|o] (more ...) Swap 1st and 2nd column on input and/or output.
-^ or just - Print a short message about the syntax of the command, then exits (NOTE: on Windows use
just -).
-+ or just + Print an extensive usage (help) message, including the explanation of any module-specific
option (but not the GMT common options), then exits.
-? or no arguments Print a complete usage (help) message, including the explanation of options, then
exits.
2.3.6 References
Bomford, G., Geodesy, 4th ed., Oxford University Press, 1980.
Aki, K. and P. Richards, Quantitative Seismology, Freeman, 1980.
F. A. Dahlen and Jeroen Tromp, Theoretical Seismology, Princeton, 1998, p.167. Definition of scalar
moment.
Cliff Frohlich, Cliffs Nodes Concerning Plotting Nodal Lines for P, Sh and Sv
Seismological Research Letters, Volume 67, Number 1, January-February, 1996
Thorne Lay, Terry C. Wallace, Modern Global Seismology, Academic Press, 1995, p.384.
W.H. Press, S.A. Teukolsky, W.T. Vetterling, B.P. Flannery, Numerical Recipes in C, Cambridge University press (routine jacobi)
2.3.7 Author
Genevieve Patau, Laboratory of Seismogenesis <http://www.ipgp.fr/rech/sismogenese/>, Institut de
Physique du Globe de Paris, Departement de Sismologie, Paris, France
2.4 psmeca
psmeca - Plot focal mechanisms on maps
342
2.4.1 Synopsis
psmeca [ table ] -Jparameters -Rregion [ -B[p|s]parameters ] [ -C[pen][Ppointsize] ] [ Ddepmin/depmax ] [ -Efill] [ -Fmode[args] ] [ -Gfill] [ -K ] [ -L[pen] ] [ -M ] [ -N ] [ -O ] [ -P ] [
-S<format><scale>[/d]] [ -Tnum_of_plane[pen] ] [ -U[stamp] ] [ -V[level] ] [ -Wpen ] [ -Xx_offset ] [
-Yy_offset ] [ -Zcpt] [ -ccopies ] [ -dinodata ] [ -hheaders ] [ -iflags ] [ -ttransp ] [ -:[i|o] ]
Note: No space is allowed between the option flag and the associated arguments.
2.4.2 Description
psmeca reads data values from files [or standard input] and generates PostScript code that will plot focal
mechanisms on a map. Most options are the same as for psxy. The PostScript code is written to standard
output.
2.4. psmeca
343
1,2: longitude, latitude of event (-: option interchanges order) 3: depth of event in kilometers
4,5,6: strike, dip and rake in degrees 7: magnitude 8,9: longitude, latitude at which to place
beach ball. Entries in these columns are necessary with the -C option. Using 0,0 in columns
8 and 9 will plot the beach ball at the longitude, latitude given in columns 1 and 2. The -:
option will interchange the order of columns (1,2) and (8,9). 10: Text string to appear above
or below the beach ball (optional).
-Scscale[/fontsize[/offset[u]]]
Focal mechanisms in Harvard CMT convention. scale adjusts the scaling of the radius of the beach
ball, which will be proportional to the magnitude. Scale is the size for magnitude = 5 (that is M0
= 4.0E23 dynes-cm) in inch (unless c, i, or p is appended). Use the -T option to render the beach
ball transparent by drawing only the nodal planes and the circumference. The color or shade of the
compressive quadrants can be specified with the -G option. The color or shade of the extensive quadrants
can be specified with the -E option. Append u to have the text appear below the beach ball (default is
above). Parameters are expected to be in the following columns:
1,2: longitude, latitude of event (-: option interchanges order) 3: depth of event in kilometers
4,5,6: strike, dip, and rake of plane 1 7,8,9: strike, dip, and rake of plane 2 10,11: mantissa
and exponent of moment in dyne-cm 12,13: longitude, latitude at which to place beach ball.
Entries in these columns are necessary with the -C option. Using (0,0) in columns 12 and
13 will plot the beach ball at the longitude, latitude given in columns 1 and 2. The -: option
will interchange the order of columns (1,2) and (12,13). 14: Text string to appear above or
below the beach ball (optional).
-Sm|d|zscale[/fontsize[/offset[u]]]
Seismic moment tensor (Harvard CMT, with zero trace). scale adjusts the scaling of the radius of the
beach ball, which will be proportional to the magnitude. Scale is the size for magnitude = 5 (that
is scalar seismic moment = 4.0E23 dynes-cm) in inch (unless c, i, m, or p is appended). (-T0 option
overlays best double couple transparently.) Use -Sm to plot the Harvard CMT seismic moment tensor
with zero trace. Use -Sd to plot only the double couple part of moment tensor. Use -Sz to plot the
anisotropic part of moment tensor (zero trace). The color or shade of the compressive quadrants can be
specified with the -G option. The color or shade of the extensive quadrants can be specified with the
-E option. Append u to have the text appear below the beach ball (default is above). Parameters are
expected to be in the following columns:
1,2: longitude, latitude of event (-: option interchanges order) 3: depth of event in kilometers 4,5,6,7,8,9: mrr, mtt, mff, mrt, mrf, mtf in 10*exponent dynes-cm 10: exponent 11,12:
longitude, latitude at which to place beach ball. Entries in these columns are necessary with
the -C option. Using (0,0) in columns 11 and 12 will plot the beach ball at the longitude,
latitude given in columns 1 and 2. The -: option will interchange the order of columns (1,2)
and (11,12). 13: Text string to appear above or below the beach ball (optional).
-Spscale[/fontsize[/offset[u]]]
Focal mechanisms given with partial data on both planes. scale adjusts the scaling of the radius of the
beach ball, which will be proportional to the magnitude. Scale is the size for magnitude = 5 in inch
(unless c, i, or p is appended). The color or shade of the compressive quadrants can be specified with the
-G option. The color or shade of the extensive quadrants can be specified with the -E option. Append
u to have the text appear below the beach ball (default is above). Parameters are expected to be in the
following columns:
1,2: longitude, latitude of event (-: option interchanges order) 3: depth of event in kilometers
4,5: strike, dip of plane 1 6: strike of plane 2 7: must be -1/+1 for a normal/inverse fault 8:
magnitude 9,10: longitude, latitude at which to place beach ball. Entries in these columns
344
are necessary with the -C option. Using (0,0) in columns 9 and 10 will plot the beach ball at
the longitude, latitude given in columns 1 and 2. The -: option will interchange the order of
columns (1,2) and (9,10). 11: Text string to appear above or below the beach ball (optional).
-Sx|y|tscale[/fontsize[/offset[u]]]
Principal axis. scale adjusts the scaling of the radius of the beach ball, which will be proportional to
the magnitude. Scale is the size for magnitude = 5 (that is seismic scalar moment = 4*10e+23 dynes-cm)
in inch (unless c, i, or p is appended). (-T0 option overlays best double couple transparently.) Use -Sx
to plot standard Harvard CMT. Use -Sy to plot only the double couple part of moment tensor. Use -St
to plot zero trace moment tensor. The color or shade of the compressive quadrants can be specified with
the -G option. The color or shade of the extensive quadrants can be specified with the -E option. Append
u to have the text appear below the beach ball (default is above). Parameters are expected to be in the
following columns:
1,2: longitude, latitude of event (-: option interchanges order) 3: depth of event in kilometers
4,5,6,7,8,9,10,11,12: value (in 10*exponent dynes-cm), azimuth, plunge of T, N, P axis. 13:
exponent 14,15: longitude, latitude at which to place beach ball. Entries in these columns
are necessary with the -C option. Using (0,0) in columns 14 and 15 will plot the beach
ball at the longitude, latitude given in columns 1 and 2. The -: option will interchange the
order of columns (1,2) and (14,15). 16: Text string to appear above or below the beach ball
(optional).
2.4. psmeca
345
2.4.5 Examples
The following file should give a normal-faulting CMT mechanism:
346
gmt psmeca -R239/240/34/35.2 -Jm4c -Sc0.4 -h1 << END > test.ps
lon lat depth str dip slip st dip slip mant exp plon plat
239.384 34.556 12. 180 18 -88 0 72 -90 5.5 0 0 0
END
2.4.7 References
Bomford, G., Geodesy, 4th ed., Oxford University Press, 1980.
Aki, K. and P. Richards, Quantitative Seismology, Freeman, 1980.
F. A. Dahlen and Jeroen Tromp, Theoretical Seismology, Princeton, 1998, p.167.
Cliff Frohlich, Cliffs Nodes Concerning Plotting Nodal Lines for P, Sh and Sv
Seismological Research Letters, Volume 67, Number 1, January-February, 1996
Thorne Lay, Terry C. Wallace, Modern Global Seismology, Academic Press, 1995, p.384.
W.H. Press, S.A. Teukolsky, W.T. Vetterling, B.P. Flannery, Numerical Recipes in C, Cambridge University press (routine jacobi)
2.4.8 Authors
Genevieve Patau, Laboratory of Seismogenesis <http://www.ipgp.fr/rech/sismogenese/>, Institut de
Physique du Globe de Paris, Departement de Sismologie, Paris, France
2.5 pspolar
pspolar - Plot polarities on the inferior focal half-sphere on maps
2.5.1 Synopsis
pspolar [ table ] -Dlon/lat -Jparameters -Rregion -Msize -S<symbol><size> [ -B[p|s]parameters ] [
-Clon/lat[/dash_width/pointsize] ] [ -Ecolor ] [ -Fcolor ] [ -Gcolor ] [ -K ] [ -L ] [ -N ] [ -O ] [ Qmode[args] ] [ -Tangle/form/justify/fontsize ] [ -U[stamp] ] [ -V[level] ] [ -Wpen ] [ -Xx_offset ] [
-Yy_offset ] [ -ccopies ] [ -dinodata ] [ -hheaders ] [ -iflags ] [ -ttransp ] [ -:[i|o] ]
Note: No space is allowed between the option flag and the associated arguments.
2.5.2 Description
pspolar reads data values from files [or standard input] and generates PostScript code that will plot
stations on focal mechanisms on a map. The PostScript code is written to standard output.
Parameters are expected to be in the following columns:
2.5. pspolar
347
348
2.5. pspolar
349
2.5.6 Examples
gmt pspolar -R239/240/34/35.2 -JM8c -N -Sc0.4 -h1 -D39.5/34.5 -M5 << END > test.ps
#stat azim ih pol
0481 11 147 c
6185 247 120 d
0485 288 114 +
0490 223 112 -
350
or
gmt pspolar -R239/240/34/35.2 -JM8c -N -Sc0.4 -h1 -D239.5/34.5 -M5 <<END > test.ps
#Date Or. time stat azim ih
910223 1 22 0481 11 147 ipu0
910223 1 22 6185 247 120 ipd0
910223 1 22 0485 288 114 epu0
910223 1 22 0490 223 112 epd0
910223 1 22 0487 212 109 epu0
END
2.5.8 References
Bomford, G., Geodesy, 4th ed., Oxford University Press, 1980.
Aki, K. and P. Richards, Quantitative Seismology, Freeman, 1980.
2.5.9 Authors
Genevieve Patau, Laboratory of Seismogenesis <http://www.ipgp.fr/rech/sismogenese/>, Institut de
Physique du Globe de Paris, Departement de Sismologie, Paris, France
2.6 psvelo
psvelo - Plot velocity vectors, crosses, and wedges on maps
2.6.1 Synopsis
psvelo [ table ] -Jparameters -Rregion [ -Aparameters ] [ -B[p|s]parameters ] [ -Fcolor ] [ -Ecolor ] [
-Gcolor ] [ -K ] [ -L ] [ -N ] [ -O ] [ -P ] [ -Ssymbol/scale/conf /font_size ] [ [ -U[stamp] ] [ -V[level] ] [
-Wpen ] [ -Xx_offset ] [ -Yy_offset ] [ -ccopies ] [ -dinodata ] [ -hheaders ] [ -iflags ] [ -ttransp ] [ -:[i|o]
]
Note: No space is allowed between the option flag and the associated arguments.
2.6.2 Description
psvelo reads data values from files [or standard input] and generates PostScript code that will plot velocity arrows on a map. Most options are the same as for psxy, except -S. The PostScript code is written
to standard output. The previous version (psvelomeca) is now obsolete. It has been replaced by psvelo
and psmeca.
2.6. psvelo
351
352
the 2-dimensional confidence limit for the ellipse, e.g., 0.95 for 95% confidence
ellipse. Fontsize sets the size of the text in points. The ellipse will be filled with
the color or shade specified by the -G option [default transparent]. The arrow and
the circumference of the ellipse will be drawn with the pen attributes specified
by the -W option. Parameters are expected to be in the following columns:
1,2: longitude, latitude, of station (-: option interchanges order) 3,4:
eastward, northward velocity (-: option interchanges order) 5,6: semimajor, semi-minor axes 7: counter-clockwise angle, in degrees, from
horizontal axis to major axis of ellipse. 8: name of station (optional)
-Swwedge_scale/wedge_mag.
Rotational wedges. Wedge_scale sets the size of the wedges in inches (unless c,
i, or p is appended). Values are multiplied by Wedge_mag before plotting. For
example, setting Wedge_mag to 1.e7 works well for rotations of the order of 100
nanoradians/yr. Use -G to set the fill color or shade for the wedge, and -E to
set the color or shade for the uncertainty. Parameters are expected to be in the
following columns:
1,2: longitude, latitude, of station (-: option interchanges order) 3: rotation in radians 4: rotation uncertainty in radians
-Sxcross_scale
gives Strain crosses. Cross_scale sets the size of the cross in inches (unless c, i,
or p is appended). Parameters are expected to be in the following columns:
1,2: longitude, latitude, of station (-: option interchanges order) 3: eps1,
the most extensional eigenvalue of strain tensor, with extension taken
positive. 4: eps2, the most compressional eigenvalue of strain tensor,
with extension taken positive. 5: azimuth of eps2 in degrees CW from
North.
2.6. psvelo
353
-N Do NOT skip symbols that fall outside the frame boundary specified by -R. [Default plots symbols
inside frame only].
-O (more ...) Append to existing PostScript plot.
-P (more ...) Select Portrait plot orientation.
-U[just/dx/dy/][c|label] (more ...) Draw GMT time stamp logo on plot.
-V[level] (more ...) Select verbosity level [c].
-W Set pen attributes for velocity arrows, ellipse circumference and fault plane edges. [Defaults: width
= default, color = black, style = solid].
-X[a|c|f|r][x-shift[u]]
-Y[a|c|f|r][y-shift[u]] (more ...) Shift plot origin.
-ccopies (more ...) Specify number of plot copies [Default is 1].
-dinodata (more ...) Replace input columns that equal nodata with NaN.
-h[i|o][n][+c][+d][+rremark][+rtitle] (more ...) Skip or produce header record(s).
-icols[l][sscale][ooffset][,...] (more ...) Select input columns (0 is first column).
-t[transp] (more ...) Set PDF transparency level in percent.
-:[i|o] (more ...) Swap 1st and 2nd column on input and/or output.
-^ or just - Print a short message about the syntax of the command, then exits (NOTE: on Windows use
just -).
-+ or just + Print an extensive usage (help) message, including the explanation of any module-specific
option (but not the GMT common options), then exits.
-? or no arguments Print a complete usage (help) message, including the explanation of options, then
exits.
circle, or a for arrow head [Default]. Further append l|r to only draw the left or right side of
this head [both sides]. Cannot be combined with +b or +e.
+nnorm scales down vector attributes (pen thickness, head size) with decreasing length,
where vectors shorter than norm will have their attributes scaled by length/norm [arrow
attributes remains invariant to length].
+oplon/plat specifies the oblique pole for the great or small circles. Only needed for great
circles if +q is given.
+p[-][pen] sets the vector pen attributes. If pen has a leading - then the head outline is not
drawn. [Default pen is used, and head outline is drawn]
+q means the input angle, length data instead represent the start and stop opening angles of
the arc segment relative to the given point.
+r draws half-arrows, using only the right side of specified heads [both sides].
t[b|e]trim will shift the beginning or end point (or both) along the vector segment by the
given trim; append suitable unit. If the modifiers b|e are not used then trim may be two
values separated by a slash, which is used to specify different trims for the two ends. Positive
trims will shorted the vector while negative trims will lengthen it [no trim].
In addition, all but circular vectors may take these modifiers:
+jjust determines how the input x,y point relates to the vector. Choose from beginning
[default], end, or center.
+s means the input angle, length are instead the x, y coordinates of the vector end point.
Finally, Cartesian vectors may take these modifiers:
+zscale[unit] expects input dx,dy vector components and uses the scale to convert to polar
coordinates with length in given unit.
2.6.6 Examples
The following should make big red arrows with green ellipses, outlined in red. Note that the 39% confidence scaling will give an ellipse which fits inside a rectangle of dimension Esig by Nsig.
gmt psvelo << END -h2 -R-10/10/-10/10 -W0.25p,red -Ggreen -L -Se0.2/0.39/18 \
-B1g1 -Jx0.4/0.4 -A0.3p -P -V > test.ps
#Long. Lat. Evel Nvel Esig Nsig CorEN SITE
#(deg) (deg) (mm/yr) (mm/yr)
0. -8. 0.0 0.0 4.0 6.0 0.500 4x6
-8. 5. 3.0 3.0 0.0 0.0 0.500 3x3
0. 0. 4.0 6.0 4.0 6.0 0.500
-5. -5. 6.0 4.0 6.0 4.0 0.500 6x4
5. 0. -6.0 4.0 6.0 4.0 -0.500 -6x4
0. -5. 6.0 -4.0 6.0 4.0 -0.500 6x-4
END
This example should plot some residual rates of rotation in the Western Transverse Ranges, California.
The wedges will be dark gray, with light gray wedges to represent the 2-sigma uncertainties.
gmt psvelo << END -Sw0.4/1.e7 -W0.75p -Gdarkgray -Elightgray -h1 -D2 -Jm2.2 \
-R240./243./32.5/34.75 -Bf10ma60m/WeSn -P > test.ps
#lon lat spin(rad/yr) spin_sigma (rad/yr)
241.4806 34.2073 5.65E-08 1.17E-08
241.6024 34.4468 -4.85E-08 1.85E-08
241.0952 34.4079 4.46E-09 3.07E-08
241.2542 34.2581 1.28E-07 1.59E-08
2.6. psvelo
355
242.0593
241.0553
241.1993
241.1084
END
34.0773
34.5369
33.1894
34.2565
-6.62E-08 1.74E-08
-2.38E-07 4.27E-08
-2.99E-10 7.64E-09
2.17E-08 3.53E-08
2.6.8 References
Bomford, G., Geodesy, 4th ed., Oxford University Press, 1980.
2.6.9 Authors
Kurt L. Feigl, Department of Geology and Geophysics at University of Wisconsin-Madison, Madison,
Wisconsin, USA
Genevieve Patau, Laboratory of Seismogenesis, Institut de Physique du Globe de Paris, Departement de
Sismologie, Paris, France
2.7 pssac
pssac - Plot seismograms in SAC format on maps
2.7.1 Synopsis
pssac [ saclist|SACfiles ] -Jparameters -Rregion [ -B[p|s]parameters ] [ -C[t0/t1] ] [ -Ddx[/dy] ] [ Ea|b|k|d|n[n]|u[n] ] [ -F[i][q][r] ] [ -G[p|n][+gfill][+zzero][+tt0/t1] ] [ -K ] [ -Msize[u][/alpha] ] [ -O
] [ -P ] [ -Q ] [ -Ssec_per_inch[unit] ] [ -T[+tn][+rreduce_vel][+sshift] ] [ -U[stamp] ] [ -V[level] ] [
-Wpen ] [ -Xx_offset ] [ -Yy_offset ] [ -ccopies ] [ -hheaders ] [ -ttransp ]
Note: No space is allowed between the option flag and the associated arguments.
2.7.2 Description
pssac reads SACfiles in SAC format or reads filenames and controlling parameters from saclist [or
standar input] and generates PostScript that will plot seismograms on a map. The PostScript code is
written to standard output.
356
filename [X Y [pen]]
filename is the name of SAC file to plot. X and Y are the position of seismograms to plot on a map.
On linear plots, the default X is the begin time of SAC file, which will be adjusted if -T option
is used, the default Y is determined by -E option. On geographic plots, the default X and Y are
station longitude and latitude specified in SAC header. The X and Y given here will override the
position determined by command line options. pen, if given, will override the pen from -W option
for current SAC file only.
-Jparameters (more ...) Select map projection.
-R[unit]west/east/south/north[/zmin/zmax][r] west, east, south, and north specify the region of interest, 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 w/e/s/n. The two
shorthands -Rg and -Rd stand for global domain (0/360 and -180/+180 in longitude respectively,
with -90/+90 in latitude). Alternatively for grid creation, give Rcodelon/lat/nx/ny, where code is
a 2-character combination of L, C, R (for left, center, or right) and T, M, B for top, middle, or
bottom. e.g., BL for lower left. This indicates which point on a rectangular region the lon/lat coordinate refers to, and the grid dimensions nx and ny with grid spacings via -I is used to create
the corresponding region. Alternatively, specify the name of an existing grid file and the -R settings (and grid spacing, if applicable) are copied from the grid. Using -Runit expects projected
(Cartesian) coordinates compatible with chosen -J and we inversely project to determine actual
rectangular geographic region. For perspective view (-p), optionally append /zmin/zmax. In case
of perspective view (-p), a z-range (zmin, zmax) can be appended to indicate the third dimension.
This needs to be done only when using the -Jz option, not when using only the -p option. In the
latter case a perspective view of the plane is plotted, with no third dimension.
2.7. pssac
357
q: square
r: remove mean value
i|q|r can repeat mutiple times. For example, -Frii will convert acceleration to displacement. The
order of i|q|r controls the order of the data processing.
-G[p|n][+gfill][+zzero][+tt0/t1] Paint positive or negative portion of traces. If only -G is used, default
to fill the positive portion black.
p|n controls the painting of postive portion or negative portion. Repeat -G option to
specify fills for positive and negative portions, respectively.
+gfill: color to fill
+tt0/t1: paint traces between t0 and t1 only. The reference time of t0 and t1 is determined by -T option.
+zzero: define zero line. From zero to top is positive portion, from zero to bottom is
negative portion.
-K (more ...) Do not finalize the PostScript plot.
-Msize[u][/alpha] Vertical scaling.
size[u]: scale all traces size[u] on a map. The default unit is
PROJ_LENGTH_UNIT. The scaling factor is defined as yscale =
size*(north-south)/(depmax-depmin)/map_height.
size/alpha:
alpha < 0, use the same scaling factor for all traces. The scaling factor will
scale the first trace to size[u].
alpha = 0, multiply all traces by size. No unit is allowed.
alpha > 0, multiply all traces by size*r^alpha, r is the distance range in
km.
-O (more ...) Append to existing PostScript plot.
-P (more ...) Select Portrait plot orientation.
-Q Plot traces vertically.
-Ssec_per_measure[unit] Specify the time scale in sec_per_measure seconds per unit while plotting on
geographic plots. Use PROJ_LENGTH_UNIT if unit is ommited.
-T[+tn][+rreduce_vel][+sshift] Time alignment and shift.
+ttmark: align all trace along time mark. tmark are -5(b), -4(e), -3(o), -2(a), 0-9(t0-t9).
+rreduce_vel: reduce velocity in km/s.
+sshift: shift all traces by shift seconds.
-U[just/dx/dy/][c|label] (more ...) Draw GMT time stamp logo on plot.
-V[level] (more ...) Select verbosity level [c].
-Wpen Set pen attributes for all traces unless overruled by pen specified in saclist. [Defaults: width =
default, color = black, style = solid].
-X[a|c|f|r][x-shift[u]]
358
2.7.5 Examples
To plot a single seismogram seis.SAC (generated by SAC command funcgen seismogram) and
paint positive portion black and negative portion red:
gmt pssac seis.SAC -JX10c/5c -R9/20/-2/2 -Baf -Fr -Gp+gblack -Gn+gred > single.ps
To plot several seismograms (generated by SAC command datagen sub tele *.z) on a distance
profile:
gmt pssac *.z -R200/1600/12/45 -JX15c/5c -Bx200+l'T(s)' -By5+lDegree -BWSen \
-Ed -M1.5c -W0.5p,red > distance_profile.ps
To plot seismograms (generated by SAC command datagen sub tele *.z) on a geographic map:
gmt pssac *.z -JM15c -R-120/-40/35/65 -Baf -M1i -S1500c -K > map.ps
saclst stlo stla f *.z | gmt psxy -J -R -St0.4c -Gblack -i1,2 -O >> map.ps
2.7.7 References
Refer to SAC User Manual for more details on SAC format and SAC header variables.
2.7.8 Authors
Dongdong Tian, School of Earth and Space Sciences, University of Science and Technology of China,
Hefei, Anhui, China
2.8 mgd77convert
mgd77convert - Convert MGD77 data to other file formats
2.8. mgd77convert
359
2.8.1 Synopsis
mgd77convert NGDC-ids -Fa|c|m |t -T[+]a|c|m|t [ -C ] [ -D ] [ -L[w][e][+] ] [ -V[level] ]
Note: No space is allowed between the option flag and the associated arguments.
2.8.2 Description
mgd77convert reads versions of MGD77 files and writes the same data in (probably) another format to
a new file in the current directory. Both pre- and post-Y2K MGD77 formats can be processed.
360
-L[w][e][+] Set the level of verification reporting [none] and where to send such reports [stderr]. Append a combination of w for warnings, e for errors, and + to send such log information to stdout.
-V[level] (more ...) Select verbosity level [c].
-^ or just - Print a short message about the syntax of the command, then exits (NOTE: on Windows use
just -).
-+ or just + Print an extensive usage (help) message, including the explanation of any module-specific
option (but not the GMT common options), then exits.
-? or no arguments Print a complete usage (help) message, including the explanation of options, then
exits.
2.8.5 Examples
To convert a large set of a77,h77 pairs to proper mgd77 files, try
gmt mgd77convert -C *.h77
To convert 01010047.mgd77 and 01010008.mgd77 to new netCDF .nc files, and capture all verification
messages, try
gmt mgd77convert 01010047 01010008 -Fa -Tc -V -Lew+ > log.lis
To convert 01010047.nc back to MGD77 ASCII and make sure it is identical to the original file, try
(Bourne shell syntax)
orig=`gmt mgd77path 01010047 -Ic`
gmt mgd77convert 01010047 -Fc -Ta -V
diff $orig 01010047.mgd77
To convert 01010047.nc to a plain ASCII table for manual editing, overwriting any existing table, try
gmt mgd77convert 01010047 -Fc -T+t -V
To recover the original NGDC MGD77 version of 01020051.nc and ignore any E77 corrections, use
gmt mgd77convert 01020051 -FC -Ta -V
2.8. mgd77convert
361
2.8.9 References
ncBrowse, see http://www.epic.noaa.gov/java/ncBrowse/ ncView, see http://meteora.ucsd.edu/~pierce/
ncview_home_page/ The Marine Geophysical Data Exchange Format - MGD77, see http://www.ngdc.
noaa.gov/mgg/dat/geodas/docs/mgd77.txt
2.9 mgd77info
mgd77info - Extract information about MGD77 files
2.9.1 Synopsis
mgd77info NGDC-ids [ -C[m|e] ] [ -E[m|e] ] [ -Iignore ] [ -Mf[item]|r|e|h ] [ -L[v] ] [ -V[level] ]
Note: No space is allowed between the option flag and the associated arguments.
2.9.2 Description
mgd77info reads <legid>.[mgd77|nc] files and produces a single record of information about each cruise
specified. The information includes beginning and end times, total track distances in km, longitude and
latitude range, and the total number of geophysical observations. Optionally, choose instead to see the
original MGD77 header meta-data section or its individual members.
If you need to know which tracks are crossing through a given region and what kinds of geophysical observations are available, consider using the x2sys tools to set up a tracks index data base (see x2sys_init
for more information).
362
(See mgd77info -L for agency and vessel codes). The .mgd77 or .nc extensions will automatically be appended, if needed (use -I to ignore certain file types). Cruise files will be looked for first
in the current directory and second in all directories listed in $MGD77_HOME/mgd77_paths.txt
[If $MGD77_HOME is not set it will default to $GMT_SHAREDIR/mgd77].
2.9. mgd77info
363
2.9.5 Examples
To get one-line summary information about the cruises 01010047.mgd77 and 01010008.mgd77, try
gmt mgd77info 01010047 01010008 -E > listing.lis
To see the original raw MGD77 header meta-data for cruise 01010047.mgd77, run
gmt mgd77info 01010047 -Mr
To determine all the parameters related to Gravity during cruise 01010047.mgd77, run
gmt mgd77info 01010047 -Mf | grep Gravity
To determine the Magnetic sampling rate used during cruise 01010047.mgd77, run
gmt mgd77info 01010047 -MfMagnetics_Sampling_Rate
To see all the columns that the MGD77+ cruise 01010047.nc contains, run
gmt mgd77info 01010047 -C
To see the E77 status of all MGD77+ cruises collected by the University of Hawaii (institution 08), run
gmt mgd77info 08 -Ia -Me
2.9.7 References
The Marine Geophysical Data Exchange Format - MGD77, see http://www.ngdc.noaa.gov/mgg/dat/
geodas/docs/mgd77.txt.
2.10 mgd77list
mgd77list - Extract data from MGD77 files
2.10.1 Synopsis
mgd77list NGDC-ids -Fcolumns[,logic][:bittests] [ -A[+]c|d|f|m|tcode ] [ -Cf|g|e ] [ -DA|astartdate ]
[ -DB|bstopdate ] [ -E ] [ -Gastartrec ] [ -Gbstoprec ] [ -Iignore ] [ -L[corrtable] ] [ -Nd|sunit ] [
-Qa|c|vmin/max ] [ -Rregion ] [ -Sastartdist[unit] ] [ -Sbstopdist[unit] ] [ -T[m|e] ] [ -V[level] ] [ Wweight ] [ -Z+|- ] [ -bobinary ] [ -hheaders ]
Note: No space is allowed between the option flag and the associated arguments.
364
2.10.2 Description
mgd77list reads <NGDC-id>.[mgd77|nc] files and produces an ASCII [or binary] table. The <NGDCid>.[mgd77|nc] files contain track information such as leg-id, time and position, geophysical observables
such as gravity, magnetics, and bathymetry, and control codes and corrections such as Eotvos and diurnal corrections. The MGD77+ extended netCDF files may also contain additional user columns (for
a listing of available columns, use mgd77info -C, and to learn how to add your own custom columns,
see mgd77manage). The user may extract any combination of these parameters, any of 8 computed
quantities (distance, heading, course-change, velocity, Carter correction, Eotvos correction and gravity
and magnetic global reference fields), calendar sub-units of time (year, month, day, hour, min, sec), the
NGDC id, and finally a preset weight (see -W). A sub-section can be specified by passing time- or
distance-intervals along track or by selecting a geographical region. Finally, each output record may be
required to pass any number of logical tests involving data values or bit flags. If multiple cruises are
requested then they are separated by segment headers.
2.10. mgd77list
365
366
367
ways to adjust the data. Append c(arter), d(epth), f(aa), or m(ag) and select the code for the procedure you want applied. You may select more than one procedure for a data column by summing
their numerical codes (1, 2, 4, and 8). E.g., -Ac3 will first try method -Ac1 to estimate a Carter
correction but if depth is NaN we will next try -Ac2 which only uses twt. In all cases, if any of
the values required by an adjustment procedure is NaN then the result will be NaN. This is also
true if the original anomaly is NaN. Specify -A+ to recalculate anomalies even if the anomaly in
the file is NaN. Additionally, you can use -At to create fake times for cruises that has no time;
these are based on distances and cruise duration.
-Ac Determines how the carter correction term is calculated. Below, C(twt) stands for the Cartercorrected depth (it also depends on lon, lat), U(twt, v) is the uncorrected depth (= twt * v / 2)
using as v the Assumed Sound Velocity parameter in the MGD77 header (if it is a valid velocity, otherwise we default to 1500 m/s); alternatively, append your preferred velocity v in m/s,
TU(depth, v) is the 2-way travel time estimated from the (presumably) uncorrected depth, and
TC(depth) is the 2-way travel time obtained by inverting the (presumably) corrected depth using
the Carter correction formula. Select from
-Ac1[,v] returns difference between U(twt, v) and depth [Default].
-Ac2[,v] returns difference between U(twt, v) and Carter (twt).
-Ac4[,v] returns difference between (assumed uncorrected) depth and Carter (TU(depth)).
-Ac8[,v] returns difference between U(TC(depth), v) and depth.
-Ad Determines how the depth column output is obtained:
-Ad1 returns depth as stored in the data set [Default].
-Ad2[,v] returns calculated uncorrected depth U(twt, v).
-Ad4 returns calculated corrected depth C(twt).
-Af Determines how the faa column output is obtained. If ngrav (i.e., the International Gravity reference
Field (IGF), or normal gravity) is required it is selected based on the MGD77 header parameter
Theoretical Gravity Formula Code; if this code is not present or is invalid we default to 4.
Alternatively, append the preferred field (1-4) to select 1 (Heiskanen 1924), 2 (IGF 1930), 3 (IGF
1967) or 4 (IGF 1980). Select from
-Af1[,field] returns faa as stored in the data set [Default]. Optionally, sets the IGF field to use if
you also have requested ngrav as an output column in -F.
-Af2[,field] returns the difference between gobs and ngrav (with optional field directive).
-Af4[,field] returns the combination of gobs + eot - ngrav (with optional field directive).
-Af8[,field] returns the combination of gobs + pred_eot - ngrav (with optional field directive).
-Am Determines how the mag column output is obtained. There may be one or two total field measurements in the file (mtf1 and mtf2), and the column msens may state which one is the leading
sensor (1 or 2; it may also be undefined). Select from
-Am1 returns mag as stored in the data set [Default].
-Am2 returns the difference between mgfx and igrf, where x is the leading sensor (1 or 2) indicated by the msens data field (defaults to 1 if unspecified).
-Am4 returns the difference between mgfx and igrf, where x is the sensor (2 or 1) not indicated
by the msens data field (defaults to 2 if unspecified).
368
-Amc<offset>[unit] Apply a correction that tries to compensate the fact that the magnetic field
was not acquired at the same position as the navigation refer (ships position). This is accomplished by re-interpolating the total magnetic field to what it would have had if it was measured
at the ships position (remember, it probably was measured <offset> meters behind). Due to this
interpolation step, bad navigation, namely too many repeated points, may cause troubles. Measures are taken to minimize this effect but they arent 100% full prof. The interpolation method is
controlled by the GMT default GMT_INTERPOLANT. Append e for meter, f for feet, k for km,
m for miles, n for nautical miles, or u for survey feet [Default is e (meters)].
-Cf|g|e Append a one-letter code to select the procedure for along-track distance calculation (see -N for
selecting units):
f Flat Earth distances.
g Great circle distances [Default].
e Geodesic distances on current GMT ellipsoid.
-Dastartdate Do not list data collected before startdate (yyyy-mm-ddBD(T)[hh:mm:ss]) [Default is
start of cruise]. Use -DA to exclude records whose time is undefined (i.e., NaN). [Default reports
those records].
-Dbstopdate Do not list data collected on or after stopdate (yyyy-mm-ddBD(T)[hh:mm:ss]). [Default is
end of cruise]. Use -DB to exclude records whose time is undefined (i.e., NaN). [Default reports
those records].
-E Exact match: Only output records that match all the requested geophysical columns [Default outputs
records that matches at least one of the observed columns].
-Gastartrec Do not list records before startrec [Default is 0, the first record].
-Gbstoprec Do not list data after stoprec. [Default is the last record].
-Iignore Ignore certain data file formats from consideration. Append a|c|m|t to ignore MGD77 ASCII,
MGD77+ netCDF, MGD77 t ASCII, or plain tab-separated ASCII table files, respectively. The
option may be repeated to ignore more than one format. [Default ignores none].
-L[corrtable] Apply optimal corrections to columns where such corrections are available. Append
the correction table to use [Default uses the correction table mgd77_corrections.txt in the
$MGD77_HOME directory]. For the format of this file, see CORRECTIONS below.
-n Issue a segment header record with cruise ID for each cruise.
-Nd|sunit Append d for distance or s for speed, then give the desired unit as e (meter or m/s), f (feet or
feet/s), k (km or km/hr), m (miles or miles/hr), n (nautical miles or knots), or u (survey feet or
sfeet/s). [Default is -Ndk -Nse (km and m/s)].
-Qamin/max Specify an accepted range (min/max) of azimuths. Records whose track azimuth falls
outside this range are ignored [0/360].
-Qcmin/max Specify an accepted range (min/max) of course changes. Records whose track course
change falls outside this range are ignored [-360/+360]. Use -QC to take the absolute value of
the course change before the test [Default uses signed course changes].
-Qvmin/max Specify an accepted range (min/max; or just min if there is no upper limit) of velocities.
Records whose track speed falls outside this range are ignored [0/infinity].
-R[unit]west/east/south/north[/zmin/zmax][r] west, east, south, and north specify the region of interest, 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 w/e/s/n. The two
2.10. mgd77list
369
shorthands -Rg and -Rd stand for global domain (0/360 and -180/+180 in longitude respectively,
with -90/+90 in latitude). Alternatively for grid creation, give Rcodelon/lat/nx/ny, where code is
a 2-character combination of L, C, R (for left, center, or right) and T, M, B for top, middle, or
bottom. e.g., BL for lower left. This indicates which point on a rectangular region the lon/lat coordinate refers to, and the grid dimensions nx and ny with grid spacings via -I is used to create
the corresponding region. Alternatively, specify the name of an existing grid file and the -R settings (and grid spacing, if applicable) are copied from the grid. Using -Runit expects projected
(Cartesian) coordinates compatible with chosen -J and we inversely project to determine actual
rectangular geographic region. For perspective view (-p), optionally append /zmin/zmax. In case
of perspective view (-p), a z-range (zmin, zmax) can be appended to indicate the third dimension.
This needs to be done only when using the -Jz option, not when using only the -p option. In the
latter case a perspective view of the plane is plotted, with no third dimension.
-Sastartdist[unit] Do not list data that are less than startdist meter along track from port of departure.
Append e for meter, f for feet, k for km, m for miles, n for nautical miles, or u for survey feet
[Default is 0e (meters)].
-Sbstopdist[unit] Do not list data that are stopdist or more meters along track from port of departure.
Append e for meter, f for feet, k for km, m for miles, n for nautical miles, or u for survey feet
[Default is end of track].
-T[m|e] Turns OFF the otherwise automatic adjustment of values based on correction terms that are
stored in the MGD77+ file and used to counteract such things as wrong units used by the source
institution when creating the original MGD77 file from which the MGD77+ file derives (the option
has no effect on plain MGD77 ASCII files). Append m or e to limit the option to the MGD77 or
extended columns set only [Default applies to both].
-V[level] (more ...) Select verbosity level [c].
-Wweight Set the weight for these data. Weight output option must be set in -F. This is useful if the data
are to be processed with the weighted averaging techniques offered by blockmean, blockmedian,
and blockmode [1].
-Z+|- Append the sign you want for depth, carter, and msd values below sea level (-Z- gives negative
bathymetry) [Default is positive down].
-bo[ncols][type] (more ...) Select native binary output. ignored if -bo is selected. Likewise, string-fields
cannot be selected. Note that if time is one of the binary output columns it will be stored as Unixtime (seconds since 1970). To read this information in GMT to obtain absolute calendar time will
require you to use --TIME_SYSTEM=1.
-h[i|o][n][+c][+d][+rremark][+rtitle] (more ...) Skip or produce header record(s).
-^ or just - Print a short message about the syntax of the command, then exits (NOTE: on Windows use
just -).
-+ or just + Print an extensive usage (help) message, including the explanation of any module-specific
option (but not the GMT common options), then exits.
-? or no arguments Print a complete usage (help) message, including the explanation of options, then
exits.
2.10.5 Examples
To get a (distance, heading, gravity, bathymetry) listing from 01010047.mgd77, starting at June 3 1971
20:45 and ending at distance = 5000 km, use the following command:
370
To make input for blockmean and surface using free-air anomalies from all the cruises listed in the file
cruises.lis, but only the data that are inside the specified area, and make the output binary:
gmt mgd77list `cat cruises.lis` -Flon,lat,faa -R-40/-30/25/35 -bo > allgrav.b
To extract the locations of depths exceeding 9000 meter that were not interpolated (btc != 1) from all
the cruises listed in the file cruises.lis:
gmt mgd77list `cat cruises.lis` -F"depth,DEPTH>9000,BTC!=1" > really_deep.d
To extract dist, faa, and grav12_2 from records whose depths are shallower than 3 km and where none
of the requested fields are NaN, from all the MGD77+ netCDF files whose cruise ids are listed in the
file cruises.lis, we try
gmt mgd77list `cat cruises.lis` -E -Ia -F"dist,faa,grav12_2,depth<3000" > \
shallow_grav.d
To extract dist, faa, and grav12_2 from all the MGD77+ netCDF files whose cruise ids are listed in the
file cruises.lis, but only retrieve records whose bitflag for faa indicates BAD values, we try
gmt mgd77list `cat cruises.lis` -E -Ia -F"dist,faa,grav12_2:+faa" > bad_grav.d
To output lon, lat, mag, and faa from all the cruises listed in the file cruises.lis, but recalculate the two
residuals based on the latest reference fields, try:
gmt mgd77list `cat cruises.lis` -Flon,lat,mag,faa -Af2,4 -Am2 > data.d
2.10.7 Igrf
The IGRF calculations are based on a Fortran program written by Susan Macmillan, British Geological
Survey, translated to C via f2c by Joaquim Luis, U Algarve, and adapted to GMT-style by Paul Wessel.
2.10.8 Igf
The equations used are reproduced here using coefficients extracted directly from the source code (let
us know if you find errors):
(1) g = 978052.0 * [1 + 0.005285 * sin^2(lat) - 7e-6 * sin^2(2*lat) + 27e-6 * cos^2(lat) * cos^2(lon-18)]
(2) g = 978049.0 * [1 + 0.0052884 * sin^2(lat) - 0.0000059 * sin^2(2*lat)]
(3) g = 978031.846 * [1 + 0.0053024 * sin^2(lat) - 0.0000058 * sin^2(2*lat)]
(4) g = 978032.67714 * [(1 + 0.00193185138639 * sin^2(lat)) / sqrt (1 - 0.00669437999013 * sin^2(lat))]
2.10. mgd77list
371
2.10.9 Corrections
The correction table is an ASCII file with coefficients and parameters needed to carry out corrections.
Comment records beginning with # are allowed. All correction records are of the form
cruiseID observation correction
where cruiseID is a NGDC prefix, observation is one of the abbreviations for geophysical observations
listed under -F above, and correction consists of one or more terms that will be summed up and then
subtracted from the observation before output. Each term must have this exact syntax:
factor[*[function]([scale](abbrev[-origin]))[^power]]
where terms in brackets are optional (the brackets themselves are not used but regular parentheses must
be used as indicated). No spaces are allowed except between terms. The factor is the amplitude of the
basis function, while the optional function can be one of sin, cos, or exp. The optional scale and origin
can be used to translate the argument (before giving it to the optional function). The argument abbrev
is one of the abbreviations for observations listed above. If origin is given as T it means that we should
replace it with the value of abbrev for the very first record in the file (this is usually only done for time).
If the first record entry is NaN we revert origin to zero. Optionally, raise the entire expression to the
given power, before multiplying by the amplitude. The following is an example of fictitious corrections
to the cruise 99999999, implying the depth should have the Carter correction removed, faa should have
a linear trend removed, the magnetic anomaly (mag) should be corrected by a strange dependency on
ship heading and latitude, and gobs needs to have 10 mGal added (hence given as -10):
99999999 depth 1.0*((carter))
99999999 faa 14.1 1e-5*((time-T))
99999999 mag 0.5*cos(0.5*(azim-19))^2 1.0*exp(-1e-3(lat))^1.5
99999999 gobs -10
2.10.11 References
The Marine Geophysical Data Exchange Format - MGD77, see http://www.ngdc.noaa.gov/mgg/dat/
geodas/docs/mgd77.txt
IGRF, see http://www.ngdc.noaa.gov/IAGA/vmod/igrf/
2.11 mgd77magref
mgd77magref - Evaluate the IGRF or CM4 magnetic field models
2.11.1 Synopsis
mgd77magref [ inputfile ] [ -A[+aalt+tdate+y] ] [ -Ccm4file ] [ -DDstfile ] [ -Ef107file ] [ -Fflags ] [ -G
] [ -Sc|llow/high ] [ -V[level] ] [ -bbinary ] [ -fflags ] [ -hheaders ] [ -:[i|o] ]
372
Note: No space is allowed between the option flag and the associated arguments.
2.11.2 Description
mgd77magref will evaluate the IGRF or the CM4 geomagnetic models at the specified locations and
times.
2.11. mgd77magref
373
r means output all input columns before adding the items below
t means list total field (nT).
h means list horizontal field (nT).
x means list X component (nT, positive north).
y means list Y component (nT, positive east).
z means list Z component (nT, positive down).
d means list declination (deg, clockwise from north).
i means list inclination (deg, positive down).
Append one or more number to indicate the requested field contribution(s):
0 means IGRF field (no combinations allowed)
1 means CM4 Core field
2 means CM4 Lithospheric field
3 means CM4 Primary Magnetospheric field
4 means CM4 Induced Magnetospheric field
5 means CM4 Primary ionospheric field
6 means CM4 Induced ionospheric field
7 means CM4 Toroidal field
9 means Core field from IGRF and other contributions from CM4. DO NOT USE BOTH 0 AND
9.
Appending several numbers (1-7) will add up the different contributions. For example -Ft/12
computes the total field due to Core and Lithospheric sources. Two special cases are allowed,
which mix which Core field from IGRF and other sources from CM4. -Ft/934 computes Core
field due to IGRF plus terms 3 and 4 from CM4 (but you can add others). -Ft/934 the same as
above but output the field components. The data is written out in the order they appear in flags
[Default is -Frthxyzdi/1].
-G Specifies that coordinates are geocentric [geodetic].
-L Computes J field vectors from certain external sources.
r means output all input columns before adding the items below (all in Ampers/m).
t means list magnitude field.
x means list X component.
y means list Y component.
z means list Z or current function Psi.
Append a number to indicate the requested J contribution:
1 means Induced Magnetospheric field.
2 means Primary ionospheric field.
3 means Induced ionospheric field.
374
2.11.6 Examples
To get the CM4 Total field, Declination and Inclination due to all but lithospheric and toroidal field at a
one point location and decimal time 2000.0, try
echo -28 38 0 2000.0 | gmt mgd77magref -A+y -Ftdi/13456
To do the same as above but at noon (Universal Time) of first May 2001, try
echo -28 38 0 2001-05-01T12:00:00 | gmt mgd77magref -Ftdi/13456
2.11.8 References
Comprehensive Modeling of the Geomagnetic Field, see http://denali.gsfc.nasa.gov/cm/
The International Geomagnetic Reference Field (IGRF), see http://www.iugg.org/IAGA/iaga_pages/
pubs_prods/igrf.htm
2.11. mgd77magref
375
2.12 mgd77manage
mgd77manage - Manage the content of MGD77+ files
2.12.1 Synopsis
mgd77manage NGDC-ids [ -A[+]a|c|d|D|e|E|g|i|n|t|Tfileinfo ] [ -Cf|g|e ] [ -Dabbrev1,abbrev2,...) ] [
-Eempty ] [ -F ] [ -Iabbrev/name/unit/t/scale/offset/comment ] [ -Nunit ] [ -Rregion ] [ -V[level] ] [
-bibinary ] [ -dinodata ] [ -nflags ]
Note: No space is allowed between the option flag and the associated arguments.
2.12.2 Description
mgd77manage deals with maintaining extra custom columns in MGD77+ netCDF files. You can either
delete one or more columns, add a new column, update an existing column with new data, or supply
error correction information (*.e77 files). New data may come from a table (ASCII unless -bi is used),
be based on existing columns and certain theoretical expressions, or they may be obtained by sampling
a grid (choose between GMT grid or a Sandwell/Smith Mercator *.img grid) along track. The new data
will be appended to the MGD77+ file in the form of an extra data column of specified type. The data file
will be modified; no new file will be created. For the big issues, see the DISCUSSION section below.
376
c Create a new column that derives from existing data or formulas for corrections and reference
fields. Append c for the Carter corrections subtracted from uncorrected depths, g for the IGF
gravity reference field (a.k.a normal gravity), m for the IGRF total field magnetic reference
field, and r for recomputed magnetic anomaly (append 1 or 2 to specify which total field column
to use [1]). For gravity we choose the reference field based on the parameter Gravity Theoretical
Formula Code in the cruises MGD77 header. If this is not set or is invalid we default to the IGF
1980. You can override this behavior by appending the desired code: 1 = Heiskanen 1924, 2 =
International 1930, 3 = IGF1967, or 4 = IGF1980.
d Append filename of a two-column table with the first column holding distances along track and
the second column holding data values. If no file is given we read from stdin instead. Records
with matching distances in the MGD77+ file will be assigned the new values; at other distances
we set them to NaN. Alternatively, give upper case D instead and we will interpolate the column
at all record distances. See -N for choosing distance units and -C for choosing how distances are
calculated.
e Expects to find an e77 error/correction log from mgd77sniffer with the name NGDC_ID.e77
in the current directory or in $MGD77_HOME/E77; this file will examined and used to make
modifications to the header values, specify a systematic correction for certain columns (such as
scale and offset), specify that a certain anomaly should be recalculated from the observations
(e.g., recalculate mag from mtf1 and the latest IGRF), and add or update the special column flag
which may hold bitflags (0 = GOOD, 1 = BAD) for each data field in the standard MGD77 data
set. Any fixed correction terms found (such as needing to scale a field by 0.1 or 10 because the
source agency used incorrect units) will be written as attributes to the netCDF MGD77+ file and
applied when the data are read by mgd77list. Ephemeral corrections such as those determined by
crossover analysis are not kept in the data files but reside in correction tables (see mgd77list for
details). By default, the first character of each header line in the e77 file (which is ?, Y or N) will
be consulted to see if the corresponding adjustment should be applied. If any undecided settings
are found (i.i, ?) we will abort and make no changes. Only records marked Y will be processed.
You can override this behavior by appending one or more modifiers to the -Ae command: h will
ignore all header corrections, f will ignore all fixed systematic trend corrections, n, v, and s will
ignore bitflags pertaining to navigation, data values, and data slopes, respectively. Use -A+e to
replace any existing E77 corrections in the file with the new values. Finally, e77 corrections will
not be applied if the E77 file has not been verified. Use -AE to ignore the verification status.
g Sample a GMT geographic (lon, lat) grid along the track given by the MGD77+ file using bicubic
interpolation (however, see -n). Append name of a GMT grid file.
i Sample a Sandwell/Smith Mercator *.img grid along the track given by the MGD77+ file using
bicubic interpolation (however, see -n). Append the img grid filename, followed by the commaseparated data scale (typically 1 or 0.1), the IMG file mode (0-3), and optionally the img grid max
latitude [80.738]. The modes stand for the following: (0) Img files with no constraint code, returns
data at all points, (1) Img file with constraints coded, return data at all points, (2) Img file with
constraints coded, return data only at constrained points and NaN elsewhere, and (3) Img file with
constraints coded, return 1 at constraints and 0 elsewhere.
n Append filename of a two-column table with the first column holding the record number (0
to nrows - 1) and the second column holding data values. If no file is given we read from stdin
instead. Records with matching record numbers in the MGD77+ file will be assigned the new
values; at other records we set them to NaN.
t Append filename of a two-column table with the first column holding absolute times along track
and the second column holding data values. If no file is given we read from stdin instead. Records
with matching times in the MGD77+ file will be assigned the new values; at other times we set
2.12. mgd77manage
377
them to NaN. Alternatively, give upper case T instead and we will interpolate the column at all
record times.
-Cf|g|e Append a one-letter code to select the procedure for along-track distance calculation when using
-Ad|D (see -N for selecting distance units):
f Flat Earth distances.
g Great circle distances [Default].
e Geodesic distances on current GMT ellipsoid.
-Dabbrev1,abbrev2,...) Give a comma-separated list of column abbreviations that you want to delete
from the MGD77+ files. Do NOT use this option to remove columns that you are replacing with
new data (use -A+ instead). Because we cannot remove variables from netCDF files we must
create a new file without the columns to be deleted. Once the file is successfully created we
temporarily rename the old file, change the new filename to the old filename, and finally remove
the old, renamed file.
-Eempty Give a single character that will be repeated to fill empty string values, e.g., 9 will yield a
string like 99999... [9].
-F Force mode. When this mode is active you are empowered to delete or replace even the standard
MGD77 set of columns. You better know what you are doing!
-Iabbrev/name/unit/t/scale/offset/comment In addition to file information we must specify additional
information about the extra column. Specify a short (16 char or less, using lower case letters,
digits, or underscores only) abbreviation for the selected data, its more descriptive name, the data
unit, the data type 1-character code (byte, short, float, int, double, or text) you want used for
storage in the netCDF file, any scale and offset we should apply to the data to make them fit inside
the range implied by the chosen storage type, and a general comment (< 128 characters) regarding
what these data represent. Note: If text data type is selected then the terms values in the -A
discussion refer to your text data. Furthermore, the discussion on interpolation does not apply and
the NaN value becomes a no string value (see -E for what this is). Place quotes around terms
with more than one word (e.g., Corrected Depth).
-Nunit Append the distance unit (see UNITS). [Default is -Nk (km)]. Only relevant when -Ag|i is selected.
-R[unit]xmin/xmax/ymin/ymax[r] (more ...) Specify the region of interest. Only relevant when -Ag|i is
selected.
-V[level] (more ...) Select verbosity level [c].
-bi[ncols][t] (more ...) Select native binary input. This applies to the input 1- or 2-column data files
specified under some of the -A options. The binary input option is only available for numerical
data columns.
-dinodata (more ...) Replace input columns that equal nodata with NaN.
-n[b|c|l|n][+a][+bBC][+c][+tthreshold] (more ...) Select interpolation mode for grids.
-^ or just - Print a short message about the syntax of the command, then exits (NOTE: on Windows use
just -).
-+ or just + Print an extensive usage (help) message, including the explanation of any module-specific
option (but not the GMT common options), then exits.
-? or no arguments Print a complete usage (help) message, including the explanation of options, then
exits.
378
2.12.5 Units
For map distance unit, append unit d for arc degree, m for arc minute, and s for arc second, or e for
meter [Default], f for foot, k for km, M for statute mile, n for nautical mile, and u for US survey foot.
By default we compute such distances using a spherical approximation with great circles. Prepend - to
a distance (or the unit is no distance is given) to perform Flat Earth calculations (quicker but less
accurate) or prepend + to perform exact geodesic calculations (slower but more accurate).
2.12.7 Examples
To append Geosat/ERS-1 gravity version 11.2 as an extra data column in the cruises 01010047.nc and
01010008.nc, storing the values as mGal*10 in a 2-byte short integer, try
gmt mgd77manage 01010047 01010008 -Ai10/1/grav.11.2.img \
-Isatgrav/"Geosat/ERS-1 gravity"/"mGal"/s/10/0/"Sandwell/Smith version 11.2" V
To append a filtered version of magnetics as an extra data column of type float for the cruise
01010047.nc, and interpolate the filtered data at the times given in the MGD77+ file, try
gmt mgd77manage 01010047 -ATmymag.tm -Ifiltmag/"Intermediate-wavelength \
magnetic residuals"/"nTesla"/f/1/0/"Useful for looking for isochrons" -V
To delete the existing extra columns satfaa, coastdist, and satvgg from all MGD77+ files, try
gmt mgd77manage =allmgd77.lis -Dsatfaa,coastdist,satvgg -V
To create a 4-byte float column with the correct IGRF reference field in all MGD77+ files, try
gmt mgd77manage =allmgd77.lis -Acm -Iigrf/"IGRF reference \
field"/"nTesla"/f/1/0/"IGRF version 10 for 1990-2010" -V
2.12.8 Discussion
1. Preamble
The mgd77 supplement is an attempt to (1) improve on the limited functionality of the existing mgg
supplement, (2) incorporate some of the ideas from Scripps gmt+ supplement by allowing extra data
columns, and (3) add new capabilities for managing marine geophysical trackline data stored in an
architecture-independent CF-1.0- and COARDS-compliant netCDF file format. Here are some of the
underlying ideas and steps you need to take to maintain your files.
2. Introduction
Our starting point is the MGD77 ASCII data files distributed from NGDC on CD-ROMS, DVD-ROMS,
and via FTP. Using Geodas to install the files locally we choose the Carter corrected depth option
2.12. mgd77manage
379
which will fill in the depth column using the two-way travel-times and the Carter tables if twt is present.
This step yields ~5000 individual cruise files. Place these in one or more sub-directories of your choice,
list these sub-directories (one per line) in the file mgd77_paths.txt, and place that file in the directory
pointed to by $MGD77_HOME; if not set this variable defaults to $GMT_SHAREDIR/mgd77.
3. Conversion
Convert the ASCII MGD77 files to the new netCDF MGD77+ format using mgd77convert. Typically,
you will make a list of all the cruises to be converted (with or without extension), and you then run
mgd77convert =cruises.lis -Fa -Tc -V -Lwe+ > log.txt
The verbose settings will ensure that all problems found during conversion will be reported. The new
*.nc files may also be placed in one or more separate sub-directories and these should also be listed
in the mgd77_paths.txt file. We suggest you place the directories with *.nc files ahead of the *.mgd77
directories. When you later want to limit a search to files of a certain extension you should use the -I
option.
4. Adding new columns
mgd77manage will allow you to add additional data columns to your *.nc files. These can be anything,
including text strings, but most likely are numerical values sampled along the track from a supplied
grid or an existing column that have been filtered or manipulated for a particular purpose. The format
supports up to 32 such extra columns. See this man page for how to add columns. You may later decide
to remove some of these columns or update the data associated with a certain column. Data extraction
tools such as mgd77list can be used to extract a mix of standard MGD77 columns (navigation, time, and
the usual geophysical observations) and your custom columns.
5. Error sources
Before we discuss how to correct errors we will first list the different classes of errors associated with
MGD77 data: (1) Header record errors occur when some of the information fields in the header do not
comply with the MGD77 specification or required information is missing. mgd77convert will list these
errors when the extended verbose setting is selected. These errors typically do not affect the data and
are instead errors in the meta-data (2). Fixed systematic errors occur when a particular data column,
despite the MGD77 specification, has been encoded incorrectly. This usually means the data will be off
by a constant factor such as 10 or 0.1, or in some cases even 1.8288 which converts fathoms to meters.
(3) Unknown systematic errors occur when the instrument that recorded the data or the processing that
followed introduced signals that appear to be systematic functions of time along track, latitude, heading,
or some other combination of terms that have a physical or logical explanation. These terms may sometimes be resolved by data analysis techniques such as along-track and across-track investigations, and
will result in correction terms that when applied to the data will remove these unwanted signals in an
optimal way. Because these correction terms may change when new data are considered in their determination, such corrections are considered to be ephemeral. (4) Individual data points or sequences of data
may violate rules such as being outside of possible ranges or in other ways violate sanity. Furthermore,
sequences of points that may be within valid ranges may give rise to data gradients that are unreasonable.
The status of every point can therefore be determined and this gives rise to bitflags GOOD or BAD. Our
policy is that error sources 1, 2, and 4 will be corrected by supplying the information as meta-data in the
relevant *.nc files, whereas the corrections for error source 3 (because they will constantly be improved)
will be maintained in a separate list of corrections.
6. Finding errors
The mgd77sniffer is a tool that does a thorough along-track sanity check of the original MGD77 ASCII
files and produces a corresponding *.e77 error log. All problems found are encoded in the error log,
and recommended fixed correction terms are given, if needed. An analyst may verify that the suggested
380
corrections are indeed valid (we only want to correct truly obvious unit errors), edit these error logs and
modify such correction terms and activate them by changing the relevant code key (see mgd77sniffer
for more details). mgd77manage can ingest these error logs and (1) correct bad header records given the
suggestions in the log, (2) insert scale/offset correction terms to be used when reading certain columns,
and (3) insert any bit-flags found. Rerun this step if you later find other problems as all E77 settings or
flags will be recreated based on the latest E77 log.
7. Error corrections
The extraction program mgd77list allows for corrections to be applied on-the-fly when data are requested. First, data with BAD bitflags are suppressed. Second, data with fixed systematic correction
terms are corrected accordingly. Third, data with ephemeral correction terms will have those corrections
applied (if a correction table is supplied). All of these steps require the presence of the relevant metadata and all can be overruled by the user. In addition, users may add their own bitflags as separate data
columns and use mgd77lists logical tests to further dictate which data are suppressed from output.
2.12.9 Credits
The IGRF calculations are based on a Fortran program written by Susan Macmillan, British Geological
Survey, translated to C via f2c by Joaquim Luis, and adapted to GMT style by Paul Wessel.
2.12.11 References
The Marine Geophysical Data Exchange Format - MGD77, see http://www.ngdc.noaa.gov/mgg/dat/
geodas/docs/mgd77.txt
IGRF, see http://www.ngdc.noaa.gov/IAGA/vmod/igrf.html
2.13 mgd77path
mgd77path - Return paths to MGD77 cruises and directories
2.13.1 Synopsis
mgd77path NGDC-ids [ -A[-] ] [ -D ] [ -Iignore ] [ -V[level] ]
Note: No space is allowed between the option flag and the associated arguments.
2.13.2 Description
mgd77path returns the full pathname to one or more MGD77 files. The pathname returned for a given
cruise may change with time due to reshuffling of disks/subdirectories.
2.13. mgd77path
381
2.13.5 Examples
To obtain pathnames for cruises 01010008 and 01010007, run
gmt mgd77path 01010008 01010007
To obtain pathnames for cruises 01010008 and 01010007, but only if there are MGD77+ version in
netCDF, run
gmt mgd77path 01010008 01010007 -Ia -It
To see the list of active directories where MGD77 files might be stored, run
gmt mgd77path -D
382
2.13.7 References
The
Marine
Geophysical
Data
Exchange
*http://www.ngdc.noaa.gov/mgg/dat/geodas/docs/mgd77.txt*.
Format
MGD77,
see
2.14 mgd77sniffer
mgd77sniffer - Along-track quality control of MGD77 cruises
2.14.1 Synopsis
mgd77sniffer NGDC-ids [ -Afieldabbrev,scale,offset ] [ -Cmaxspd ] [ -Dd|e|E|f|l|m|s|v[r] ] [ Gfieldabbrev,imggrid,scale,mode or -Gfieldabbrev,grid ] [ -H ] [ -Ifieldabbrev,rec1,recN ] [ -K ] [ Lcustom-limits-file ] [ -N ] [ -Rregion ] [ -Sd|s|t ] [ -Tgap ] [ -V[level] ] [ -Wc|g|o|s|t|v|x ] [ -bobinary ]
[ -donodata ] [ -nflags ]
Note: No space is allowed between the option flag and the associated arguments.
2.14.2 Description
mgd77sniffer scans old (pre-Y2K) and new format ASCII MGD77 files for errors using point-by-point
sanity checking, along-track detection of excessive slopes, and optional comparison of cruise data with
global gravity and predicted bathymetry grids. Detected data problems are output by default as verbose
descriptions of each detected error, often resulting in multiple messages per scanned record. Data problems are optionally output (-De option) using a computer-parseable format (see E77 ERROR FORMAT
description below). Default error thresholds are derived from histograms of all MGD77 geophysical data
collected between 1952 and January, 2006. Thresholds are adjustable with the -L option.
2.14.3 Requirements
The mgd77sniffer links with Generic Mapping Tools 4.0 or later along with the supplemental GMT
packages x2sys and mgd77. See http://gmt.soest.hawaii.edu for GMT details. Grids for comparison with
cruise data may be downloaded via the web.
383
See MGD77 FIELD INFO below for field and abbreviations descriptions.
-Dv display values for the twelve position and geophysical fields for each MGD77 data record (in
this order):
lat lon twt depth mtf1 mtf2 mag diur msens gobs eot faa
See below for MGD77 FIELD INFO.
-Ginformation Compare cruise data to GMT or IMG grids. Use one of the formats below. Gfieldabbrev,imggrid,scale,mode Compare cruise data to the specified grid in Sandwell/Smith
Mercator format. Requires a valid MGD77 field abbreviation (see MGD77 FIELD INFO below)
followed by a comma, the path (if not in current directory) and grid filename, a scale to multiply
the data (1 or 0.1), and mode which stand for the following: (0) Img files with no constraint code,
returns data at all points, (1) Img file with constraints coded, return data at all points, (2) Img file
with constraints coded, return data only at constrained points and NaN elsewhere, and (3) Img
file with constraints coded, return 1 at constraints and 0 elsewhere. -Gfieldabbrev,grid Compare
cruise data to the specified grid. Requires a valid MGD77 field abbreviation (see MGD77 FIELD
INFO below) followed by a comma, then the path (if not in current directory) and grid filename.
Multiple grid comparison is supported by using separate -G calls for each grid. See GRID FILE
INFO below.
Grid comparison activates several additional error checks. (1) Re-weighted Least Squares Regression of ship versus grid data determines slope and DC shift, which when differing from expected
1 and 0, respectively, may indicate incorrectly scaled ship data, including incorrect units or instrument drift as well as erroneous gravity tie-in. (2) Accumulated ship grid offsets are computed
along-track and excessive offsets are flagged according to maxArea threshold (use -L option to
adjust maxArea). Warning: predicted bathymetry grids are constrained by cruise data so grids
and cruise data are not always independent. Comparison of cruise bathymetry with predicted
bathymetry grids also activates a navigation crossing over land check.
-H (with -G|g only) disable (or force) decimation during RLS analysis of ship and gridded data. By
default mgd77sniffer analyses both the full and decimated data sets then reports RLS statistics for
the higher correlation regression.
-Hb analyze both (default), report better of two.
-Hd to disable data decimation (equivalent to -H with no argument).
-Hf to force data decimation.
-Ifieldabbrev,rec1,recN Append a field abbreviation and the first and last record in a range of records
that should be flagged as bad (and set to NaN prior to the analysis). Repeat as many times as
needed. May not be used for multiple cruises.
-K Reverse navigation quality flags (good to bad and vice versa). May be necessary when a majority of
navigation fixes are erroneously flagged bad, which can happen when a cruises first navigation
fix is extremely erroneous. Caution! This will affect sniffer output and should only be attempted
after careful manual navigation review.
-Lcustom-limits-file Override mgd77sniffer default error detection limits. Supply path and filename to
the custom limits file. Rows not beginning with a valid MGD77 field abbreviation are ignored.
Field abbreviations are listed below in exact form under MGD77 FIELD INFO. Multiple field
limits may be modified using one default file, one field per line. Field min, max, max slope and
max area may be changed for each field. Max slope pertains to the gradient type selected using
the -S option. Max area is used by the -G option as the threshold for flagging excessive offsets
2.14. mgd77sniffer
385
from the specified grid. Dump defaults -Dl to view syntax or to quickly create an editable custom
limits file.
Example custom default file contents (see below for units):
# abbrev
twt
depth
mag
faa
min
0
0
-800
-300
max
15
11000
800
300
maxSlope
1
500
100
maxArea
0
5000
2500
Use a dash - to retain a default limit. Hint: to test your custom limits, try: mgd77sniffer -Dl
-L<yourlimitsfile>
-N Use nautical units.
-P Flag regression statistics that are outside the specified confidence level. (i.e., -P5 flags coefficients
m, b, rms, and r that fall outside 95%.)
-R[unit]west/east/south/north[/zmin/zmax][r] west, east, south, and north specify the region of interest, 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 w/e/s/n. The two
shorthands -Rg and -Rd stand for global domain (0/360 and -180/+180 in longitude respectively,
with -90/+90 in latitude). Alternatively for grid creation, give Rcodelon/lat/nx/ny, where code is
a 2-character combination of L, C, R (for left, center, or right) and T, M, B for top, middle, or
bottom. e.g., BL for lower left. This indicates which point on a rectangular region the lon/lat coordinate refers to, and the grid dimensions nx and ny with grid spacings via -I is used to create
the corresponding region. Alternatively, specify the name of an existing grid file and the -R settings (and grid spacing, if applicable) are copied from the grid. Using -Runit expects projected
(Cartesian) coordinates compatible with chosen -J and we inversely project to determine actual
rectangular geographic region. For perspective view (-p), optionally append /zmin/zmax. In case
of perspective view (-p), a z-range (zmin, zmax) can be appended to indicate the third dimension.
This needs to be done only when using the -Jz option, not when using only the -p option. In the
latter case a perspective view of the plane is plotted, with no third dimension.
-Sd|s|t Specify gradient type for along-track excessive slope checking. -Sd Calculate change in z values
along track (dz). Output is given in geophysical units, e.g., mGal. -Ss Calculate spatial gradients
(dz/ds). Output is given in geophysical units per km along the survey track, e.g., mGal/km. -St
Calculate time gradients (dz/dt) [default]. Output is given in geophysical units per second along
the survey track, e.g., mGal/sec.
-Tgap Adjusts mgd77sniffer gap handling. By default, data gaps greater than 5 km are skipped. Set to
zero to de-activate gap skipping.
-Wc|g|o|s|t|v|x Print out only certain warning types for verbose error messages. Comma delimit any
combination of c|g|o|s|t|v|x: where (c) type code warnings, (g)radient out of range, (o)ffsets from
grid (requires -G|g), (s)peed out of range, (t)ime warnings, (v)alue out of range, (x) warning
summaries. By default ALL warning messages are printed.Not compatible with any -D options.
-V[level] (more ...) Select verbosity level [c].
-bo[ncols][type] (more ...) Select native binary output. Output binary data for -Dd|f|s|v option.
-donodata (more ...) Replace output columns that equal NaN with nodata.
-n[b|c|l|n][+a][+bBC][+c][+tthreshold] (more ...) Select interpolation mode for grids.
386
-^ or just - Print a short message about the syntax of the command, then exits (NOTE: on Windows use
just -).
-+ or just + Print an extensive usage (help) message, including the explanation of any module-specific
option (but not the GMT common options), then exits.
-? or no arguments Print a complete usage (help) message, including the explanation of options, then
exits.
Abbreviation
Travel
Depth
Total
Total
Magnetic
Correction
Sensor
Gravity
Correction
Air
Units
Time
depth
Field1
Field2
mag
diur
Depth/Alt
gobs
eot
Anomaly
The new grid, etopo5_hdr.i2 in this example, contains a GMT header and can be used in the -G option
to compare cruise depth with grid values.
2.14. mgd77sniffer
387
388
0 - fine
A - time out of range
B - time decreasing
C - excessive speed
D - above sea level
E - lat undefined
F - lon undefined
VAL (value):
0 - fine
K - twt invalid
L - depth invalid
O - mtf1 invalid
etc.
GRAD (gradient):
0 - fine
K - d[twt] excessive
L - d[depth] excessive
O - d[mtf1] excessive etc.
The NAV error class has unique cases while VAL and GRAD classes are described by alphabetic
characters for each of the 24 numeric fields in MGD77 format order.
MGD77 bit-pattern w/ E77 alpha characters
|-|-|
| X W V U T S R Q P O N M L K J I H G F E D C B A | E77 Code |
| - - - - - - - - - - - - - - - - - - - - - - - - | - - - - -|
|nfegmdmmmmbbdtpllmhdmytd|FI|
|qaoosisatttcewtoaioaoezr|iD|
|catbduegffccptcntnuynat|e|
|srn21trtr|l|
|shh|d|
| - - - - - - - - - - - - - - - - - - - - - - - - | - - - - -|
| 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 | Bit place|
| - G C G C C - G G G - - G G - - - T T T T T - - | Bit type |
|-|-|
Bit types: (G)eophysical, (C)orrection, (T)ime
2.14. mgd77sniffer
389
2.14.10 Examples
To scan for excessive values or gradients, try
gmt mgd77sniffer 08010001
To compare cruise depth with ETOPO5 bathymetry and gravity with Sandwell/Smith 2 min gravity
version 11, try
mgd77sniffer 08010001 -Gdepth,/data/GRIDS/etopo5_hdr.i2 \
-Gfaa,/data/GRIDS/grav.11.2.img,0.1,1
2.14.12 References
The Marine Geophysical Data Exchange Format - MGD77, see http://www.ngdc.noaa.gov/mgg/dat/
geodas/docs/mgd77.txt.
2.15 mgd77track
mgd77track - Plot track-line map of MGD77 cruises
2.15.1 Synopsis
mgd77track NGDC-ids -Rregion -Jparameters [ -A[c][size][,spacing] ] [ -B[p|s]parameters ] [ -Cf|g|e
] [ -Dastartdate ] [ -Dbstopdate ] [ -F ] [ -Gd|t|ngap ] [ -Iignore ] [ -K ] [ -Ltrackticks ] [ -oflags ] [
-pflags ] [ -Sastartdist[u] ] [ -Sbstopdist[u] ] [ -TT|t|dms,mc,mfs,mf,mfc ] [ -U[stamp] ] [ -V[level] ] [
-W[-|+][pen] ] [ -Xx_offset ] [ -Yy_offset ] [ -ccopies ] [ -pflags ] [ -ttransp ]
Note: No space is allowed between the option flag and the associated arguments.
2.15.2 Description
mgd77track reads NGDC MGD77 cruises and creates PostScript code that will plot one or more ship
tracks on a map using the specified projection. The PostScript code is written to standard output.
3. 4-character <agency><vessel> codes, which will return all cruises from those vessels.
4. =<list>, where <list> is a table with NGDC IDs, one per line.
5. If nothing is specified we return all cruises in the data base.
(See mgd77info -L for agency and vessel codes). The .mgd77 or .nc extensions will automatically be appended, if needed (use -I to ignore certain file types). Cruise files will be looked for first
in the current directory and second in all directories listed in $MGD77_HOME/mgd77_paths.txt
[If $MGD77_HOME is not set it will default to $GMT_SHAREDIR/mgd77].
-Jparameters (more ...) Select map projection.
-R[unit]west/east/south/north[/zmin/zmax][r] west, east, south, and north specify the region of interest, 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 w/e/s/n. The two
shorthands -Rg and -Rd stand for global domain (0/360 and -180/+180 in longitude respectively,
with -90/+90 in latitude). Alternatively for grid creation, give Rcodelon/lat/nx/ny, where code is
a 2-character combination of L, C, R (for left, center, or right) and T, M, B for top, middle, or
bottom. e.g., BL for lower left. This indicates which point on a rectangular region the lon/lat coordinate refers to, and the grid dimensions nx and ny with grid spacings via -I is used to create
the corresponding region. Alternatively, specify the name of an existing grid file and the -R settings (and grid spacing, if applicable) are copied from the grid. Using -Runit expects projected
(Cartesian) coordinates compatible with chosen -J and we inversely project to determine actual
rectangular geographic region. For perspective view (-p), optionally append /zmin/zmax. In case
of perspective view (-p), a z-range (zmin, zmax) can be appended to indicate the third dimension.
This needs to be done only when using the -Jz option, not when using only the -p option. In the
latter case a perspective view of the plane is plotted, with no third dimension.
2.15. mgd77track
391
-Iignore Ignore certain data file formats from consideration. Append a|c|m|t to ignore MGD77 ASCII,
MGD77+ netCDF, MGD77 t ASCII, or plain table files, respectively. The option may be repeated
to ignore more than one format. [Default ignores none].
-K (more ...) Do not finalize the PostScript plot.
-Ltrackticks To put time/distance log-marks on the track. E.g. a500ka24ht6h means (a)nnotate every
500 km (k) and 24 h(ours), with (t)ickmarks every 500 km and 6 hours. Alternatively you may
use the modifiers d (days) and n (nautical miles).
-O (more ...) Append to existing PostScript plot.
-P (more ...) Select Portrait plot orientation.
-Sastartdist[u] Do not plot data that are less than startdist meter along track from port of departure.
Append k for km, m for miles, or n for nautical miles [Default is 0 meters].
-Sbstopdist[u] Do not plot data that are more than stopdist meter along track from port of departure.
Append k for km, m for miles, or n for nautical miles [Default is end of track].
-TT|t|dms,mc,mfs,mf,mfc Controls the attributes of the three kinds of markers (T for the first time
marker in a new day, t for additional time markers in the same day, and d for distance markers).
For each of these you can specify the 5 comma-separated attributes markersize, markercolor,
markerfontsize, markerfont, and markerfontcolor. Repeat the -T option for each marker type.
-U[just/dx/dy/][c|label] (more ...) Draw GMT time stamp logo on plot.
-W[-|+][pen] Append pen used for the trackline. [Defaults: width = default, color = black, style = solid].
A leading + will use the lookup color (via -C) for both symbol fill and outline pen color, while a
leading - will set outline pen color and turn off symbol fill.
-X[a|c|f|r][x-shift[u]]
-Y[a|c|f|r][y-shift[u]] (more ...) Shift plot origin.
-V[level] (more ...) Select verbosity level [c].
-ccopies (more ...) Specify number of plot copies [Default is 1].
-p[x|y|z]azim/elev[/zlevel][+wlon0/lat0[/z0]][+vx0/y0] (more ...) Select perspective view.
-t[transp] (more ...) Set PDF transparency level in percent.
-^ or just - Print a short message about the syntax of the command, then exits (NOTE: on Windows use
just -).
-+ or just + Print an extensive usage (help) message, including the explanation of any module-specific
option (but not the GMT common options), then exits.
-? or no arguments Print a complete usage (help) message, including the explanation of options, then
exits.
2.15.5 Examples
To generate a Mercator plot of the track of the cruise 01010007 in the area 70W to 20E, 40S to 20N, using
a Mercator scale of 0.1inch/degree, label the tracks with 10 points characters, annotate the boundaries
every 10 degrees, draw gridlines every 5 degrees, and mark the track every day and 1000 km, with ticks
every 6 hours and 250 km, and send the plot to the default printer, enter the following command:
392
2.15.7 References
The Marine Geophysical Data Exchange Format - MGD77, see http://www.ngdc.noaa.gov/mgg/dat/
geodas/docs/mgd77.txt
2.16 dimfilter
dimfilter - Directional filtering of 2-D gridded files in the space (or time) domain
2.16.1 Synopsis
dimfilter input_file.nc -Ddistance_flag -F<filtertype><width>[mode] -Goutput_file.nc N<filtertype><n_sectors> [ -Qcols ] [ -Iincrement ] [ -Rregion ] [ -T ] [ -V[level] ] [ -fflags
]
Note: No space is allowed between the option flag and the associated arguments.
2.16.2 Description
dimfilter will filter a .nc file in the space (or time) domain by dividing the given filter circle into
n_sectors, applying one of the selected primary convolution or non-convolution filters to each sector,
and choosing the final outcome according to the selected secondary filter. It computes distances using
Cartesian or Spherical geometries. The output .nc file can optionally be generated as a subregion of the
input and/or with a new -Increment. In this way, one may have extra space in the input data so that
there will be no edge effects for the output grid. If the filter is low-pass, then the output may be less
frequently sampled than the input. -Q is for the error analysis mode and only requires the total number
of columns in the input file, which contains the filtered depths. Finally, one should know that dimfilter
will not produce a smooth output as other spatial filters do because it returns a minimum median out of
N medians of N sectors. The output can be rough unless the input data is noise-free. Thus, an additional
filtering (e.g., Gaussian via grdfilter) of the DiM-filtered data is generally recommended.
2.16. dimfilter
393
The above options are fastest because they allow weight matrix to be computed only once. The
next three options are slower because they recompute weights for each latitude.
flag = 3: grid (x,y) in degrees, width in km, dx scaled by cosine(y), Cartesian distance calculation.
flag = 4: grid (x,y) in degrees, width in km, Spherical distance calculation.
-F<filtertype><width>[mode] Sets the primary filter type. Choose among convolution and nonconvolution filters. Append the filter code followed by the full diameter width. Available convolution filters are:
(b) Boxcar: All weights are equal.
(c) Cosine Arch: Weights follow a cosine arch curve.
(g) Gaussian: Weights are given by the Gaussian function.
Non-convolution filters are:
(m) Median: Returns median value.
(p) Maximum likelihood probability (a mode estimator): Return modal value. If more than one
mode is found we return their average value. Append - or + to the filter width if you rather want
to return the smallest or largest of the modal values.
-N<filtertype><n_sectors> Sets the secondary filter type and the number of bow-tie sectors. n_sectors
must be integer and larger than 0. When n_sectors is set to 1, the secondary filter is not effective.
Available secondary filters are:
(l) Lower: Return the minimum of all filtered values.
(u) Upper: Return the maximum of all filtered values.
(a) Average: Return the mean of all filtered values.
(m) Median: Return the median of all filtered values.
(p) Mode: Return the mode of all filtered values.
-Goutput_file.nc output_file.nc is the output of the filter.
-^ or just - Print a short message about the syntax of the command, then exits (NOTE: on Windows use
just -).
-+ or just + Print an extensive usage (help) message, including the explanation of any module-specific
option (but not the GMT common options), then exits.
-? or no arguments Print a complete usage (help) message, including the explanation of options, then
exits.
2.16.7 Examples
Suppose that north_pacific_dbdb5.nc is a file of 5 minute bathymetry from 140E to 260E and 0N to
50N, and you want to find the medians of values within a 300km radius (600km full width) of the output
points, which you choose to be from 150E to 250E and 10N to 40N, and you want the output values
every 0.5 degree. To prevent the medians from being biased by the sloping plane, you want to divide
the filter circle into 6 sectors and to choose the lowest value among 6 medians. Using spherical distance
calculations, you need:
gmt dimfilter north_pacific_dbdb5.nc -Gfiltered_pacific.nc -Fm600 -D4 \
-Nl6 -R150/250/10/40 -I0.5 -V
Suppose that cape_verde.nc is a file of 0.5 minute bathymetry from 32W to 15W and 8N to 25N, and you
want to remove small-length-scale features in order to define a swell in an area extending from 27.5W
to 20.5W and 12.5N to 19.5N, and you want the output value every 2 minute. Using cartesian distance
calculations, you need:
gmt dimfilter cape_verde.nc -Gt.nc -Fm220 -Nl8 -D2 -R-27.5/-20.5/12.5/19.5 -I2m -V
gmt grdfilter t.nc -Gcape_swell.nc -Fg50 -D2 -V
Suppose that you found a range of filter widths for a given area, and you filtered the given bathymetric
data using the range of filter widths (e.g., f100.nc f110.nc f120.nc f130.nc), and you want to define a
regional trend using the range of filter widths, and you want to obtain median absolute deviation (MAD)
estimates at each data point. Then, you will need to do:
gmt
gmt
gmt
gmt
grd2xyz
grd2xyz
grd2xyz
grd2xyz
2.16. dimfilter
f100.nc
f110.nc
f120.nc
f130.nc
-Z
-Z
-Z
-Z
>
>
>
>
f100.d
f110.d
f120.d
f130.d
395
2.16.8 Limitations
When working with geographic (lat, lon) grids, all three convolution filters (boxcar, cosine arch, and
gaussian) will properly normalize the filter weights for the variation in gridbox size with latitude, and
correctly determine which nodes are needed for the convolution when the filter circle crosses a periodic
(0-360) boundary or contains a geographic pole. However, the spatial filters, such as median and mode
filters, do not use weights and thus should only be used on Cartesian grids (or at very low latitudes) only.
If you want to apply such spatial filters you should project your data to an equal-area projection and run
dimfilter on the resulting Cartesian grid.
2.16.10 Reference
Kim, S.-S., and Wessel, P. (2008), Directional Median Filtering for Regional-Residual Separation of
Bathymetry, Geochem. Geophys. Geosyst., 9, Q03005, doi:10.1029/2007GC001850.
2.17 gmtflexure
gmtflexure - Compute flexural deformation of 2-D loads, forces, bending and moments
2.17.1 Synopsis
gmtflexure -Drm/rl[/ri]/rw -ETe[u]|D|file [ -A[l|r][/args] ] [ -CpPoisson ] [ -CyYoung ] [ -Fforce ] [
-Qargs] [ -S ] [ -Twfile] [ -V[level] ] [ -Wwd] [ -Zzm] [ -bibinary ] [ -hheaders ] [ -iflags ] [ -oflags ]
Note: No space is allowed between the option flag and the associated arguments.
2.17.2 Description
gmtflexure computes the flexural response to 2-D loads using a range of user-selectable options, such
as boundary conditions, pre-existing deformations, variable rigidity and restoring force, and more. The
solutions are obtained using finite difference approximations to the differential equations.
396
2.17. gmtflexure
397
-+ or just + Print an extensive usage (help) message, including the explanation of any module-specific
option (but not the GMT common options), then exits.
-? or no arguments Print a complete usage (help) message, including the explanation of options, then
exits.
2.17.7 Examples
To compute elastic plate flexure from the topography load in topo.txt, for a 10 km thick plate with typical
densities, try
gmt flexure -Qttopo.txt -E10k -D2700/3300/1035 > flex.txt
2.17.8 References
2.17.9 See Also
gmt, gravfft grdflexuregrdmath
2.18 gmtgravmag3d
gmtgravmag3d - Compute the gravity/magnetic effect of a 3-D body by the method of Okabe
2.18.1 Synopsis
gmtgravmag3d -Tpxyz_file[+m] -Tvvert_file OR -Tr|sraw_file [ -Cdensity ] [ -D ] [ -Ethickness ] [
-Fxy_file ] [ -Goutputgrid ] [ -Hf_dec/f_dip/m_int/m_dec/m_dip ] [ -Lz_observation ] [ -Sradius ] [
-Zlevel ] [ -V[level] ] [ -fg]
Note: No space is allowed between the option flag and the associated arguments.
398
2.18.2 Description
gmtgravmag3d will compute the gravity or magnetic anomaly of a body described by a set of triangles.
The output can either be along a given set of xy locations or on a grid. This method is not particularly
fast but allows computing the anomaly of arbitrarily complex shapes.
2.18. gmtgravmag3d
399
-+ or just + Print an extensive usage (help) message, including the explanation of any module-specific
option (but not the GMT common options), then exits.
-? or no arguments Print a complete usage (help) message, including the explanation of options, then
exits.
2.18.6 Examples
Suppose you ...
gmt gmtgravmag3d ...
2.18.8 Reference
Okabe, M., Analytical expressions for gravity anomalies due to polyhedral bodies and translation into
magnetic anomalies, Geophysics, 44, (1979), p 730-741.
2.19 gravfft
gravfft - Compute gravitational attraction of 3-D surfaces in the wavenumber (or frequency) domain
2.19.1 Synopsis
gravfft ingrid [ ingrid2 ] -Goutfile [ -Cn/wavelength/mean_depth/tbw ] [ Ddensity|rhogrid ] [ -En_terms ] [ -F[f[+]|g|v|n|e] ] [ -Iw|b|c|t |k ] [ -N[f|q|s|nx/ny][+a|d|h
|l][+e|n|m][+twidth][+w[suffix]][+z[p]] [ -Q ] [ -Tte/rl/rm/rw[+m] ] [ -V[level] ] [ -Wwd] [ -Zzm[zl] ] [
-fg ]
Note: No space is allowed between the option flag and the associated arguments.
2.19.2 Description
gravfft can be used into three main modes. Mode 1: Simply compute the geopotential due to the surface
given in the topo.grd file. Requires a density contrast (-D) and possibly a different observation level
(-W). It will take the 2-D forward FFT of the grid and use the full Parkers method up to the chosen
terms. Mode 2: Compute the geopotential response due to flexure of the topography file. It will take
the 2-D forward FFT of the grid and use the full Parkers method applied to the chosen isostatic model.
400
The available models are the loading from top, or elastic plate model, and the loading from below
which accounts for the plates response to a sub-surface load (appropriate for hot spot modeling - if you
believe them). In both cases, the model parameters are set with -T and -Z options. Mode 3: compute the
admittance or coherence between two grids. The output is the average in the radial direction. Optionally,
the model admittance may also be calculated. The horizontal dimensions of the grdfiles are assumed
to be in meters. Geographical grids may be used by specifying the -fg option that scales degrees to
meters. If you have grids with dimensions in km, you could change this to meters using grdedit or scale
the output with grdmath. Given the number of choices this program offers, is difficult to state what are
options and what are required arguments. It depends on what you are doing; see the examples for further
guidance.
401
b writes a fourth column with loading from below theoretical admittance, and t writes a fourth
column with elastic plate theoretical admittance.
-N[f|q|s|nx/ny][+a|[+d|h|l][+e|n|m][+twidth][+w[suffix]][+z[p]] Choose or inquire about suitable grid
dimensions for FFT and set optional parameters. Control the FFT dimension:
-Nf will force the FFT to use the actual dimensions of the data.
-Nq will inQuire about more suitable dimensions, report those, then continue.
-Ns will present a list of optional dimensions, then exit.
-Nnx/ny will do FFT on array size nx/ny (must be >= grid file size). Default chooses
dimensions >= data which optimize speed and accuracy of FFT. If FFT dimensions >
grid file dimensions, data are extended and tapered to zero.
Control detrending of data: Append modifiers for removing a linear trend:
+d: Detrend data, i.e. remove best-fitting linear trend [Default].
+a: Only remove mean value.
+h: Only remove mid value, i.e. 0.5 * (max + min).
+l: Leave data alone.
Control extension and tapering of data: Use modifiers to control how the extension and tapering
are to be performed:
+e extends the grid by imposing edge-point symmetry [Default],
+m extends the grid by imposing edge mirror symmetry
+n turns off data extension.
Tapering is performed from the data edge to the FFT grid edge [100%]. Change this
percentage via +twidth. When +n is in effect, the tapering is applied instead to the data
margins as no extension is available [0%].
Control writing of temporary results: For detailed investigation you can write the intermediate
grid being passed to the forward FFT; this is likely to have been detrended, extended by pointsymmetry along all edges, and tapered. Append +w[suffix] from which output file name(s) will be
created (i.e., ingrid_prefix.ext) [tapered], where ext is your file extension. Finally, you may save
the complex grid produced by the forward FFT by appending +z. By default we write the real and
imaginary components to ingrid_real.ext and ingrid_imag.ext. Append p to save instead the polar
form of magnitude and phase to files ingrid_mag.ext and ingrid_phase.ext.
-Q Writes out a grid with the flexural topography (with z positive up) whose average was set by -Zzm
and model parameters by -T (and output by -G). That is the gravimetric Moho. -Q implicitly
sets -N+h
-S Computes predicted gravity or geoid grid due to a subplate load produced by the current bathymetry
and the theoretical model. The necessary parameters are set within -T and -Z options. The number
of powers in Parker expansion is restricted to 1. See an example further down.
-Tte/rl/rm/rw[+m] Compute the isostatic compensation from the topography load (input grid file) on an
elastic plate of thickness te. Also append densities for load, mantle, and water in SI units. Give
average mantle depth via -Z. If the elastic thickness is > 1e10 it will be interpreted as the flexural
rigidity (by default it is computed from te and Young modulus). Optionally, append +m to write
a grid with the Mohos geopotential effect (see -F) from model selected by -T. If te = 0 then the
Airy response is returned. -T+m implicitly sets -N+h
402
-Wwd Set water depth (or observation height) relative to topography [0]. Append k to indicate km.
-Zzm[zl] Moho [and swell] average compensation depths. For the load from top model you only have
to provide zm, but for the loading from below dont forget zl.
-V[level] (more ...) Select verbosity level [c].
-fg Geographic grids (dimensions of longitude, latitude) will be converted to meters via a Flat Earth
approximation using the current ellipsoid parameters.
-^ or just - Print a short message about the syntax of the command, then exits (NOTE: on Windows use
just -).
-+ or just + Print an extensive usage (help) message, including the explanation of any module-specific
option (but not the GMT common options), then exits.
-? or no arguments Print a complete usage (help) message, including the explanation of options, then
exits.
2.19.7 Considerations
netCDF COARDS grids will automatically be recognized as geographic. For other grids geographical
grids were you want to convert degrees into meters, select -fg. If the data are close to either pole, you
should consider projecting the grid file onto a rectangular coordinate system using grdproject.
2.19. gravfft
403
2.19.9 Examples
To compute the effect of the water layer above the bat.grd bathymetry using 2700 and 1035 for the
densities of crust and water and writing the result on water_g.grd (computing up to the fourth power of
bathymetry in Parker expansion):
gmt gravfft bat.grd -D1665 -Gwater_g.grd -E4
Now subtract it from your free-air anomaly faa.grd and you will get the Bouguer anomaly. You may
wonder why we are subtracting and not adding. After all the Bouguer anomaly pretends to correct the
mass deficiency presented by the water layer, so we should add because water is less dense than the rocks
below. The answer relies on the way gravity effects are computed by the Parkers method and practical
aspects of using the FFT.
gmt grdmath faa.grd water_g.grd SUB = bouguer.grd
Want an MBA anomaly? Well compute the crust mantle contribution and add it to the sea-bottom
anomaly. Assuming a 6 km thick crust of density 2700 and a mantle with 3300 density we could repeat the command used to compute the water layer anomaly, using 600 (3300 - 2700) as the density
contrast. But we now have a problem because we need to know the mean Moho depth. That is when the
scale/offset that can be appended to the grids name comes in hand. Notice that we didnt need to do that
before because mean water depth was computed directly from data (notice also the negative sign of the
offset due to the fact that z is positive up):
gmt gravfft bat.grd=nf/1/-6000 -D600 -Gmoho_g.grd
Now, subtract it from the Bouguer to obtain the MBA anomaly. That is:
gmt grdmath bouguer.grd moho_g.grd SUB = mba.grd
To compute the Moho gravity effect of an elastic plate bat.grd with Te = 7 km, density of 2700, over a
mantle of density 3300, at an average depth of 9 km
gmt gravfft bat.grd -Gelastic.grd -T7000/2700/3300/1035+m -Z9000
If you add now the sea-bottom and Mohos effects, you will get the full gravity response of your isostatic
model. We will use here only the first term in Parker expansion.
gmt gravfft bat.grd -D1665 -Gwater_g.grd -E1
gmt gravfft bat.grd -Gelastic.grd -T7000/2700/3300/1035+m -Z9000 -E1
gmt grdmath water_g.grd elastic.grd ADD = model.grd
The same result can be obtained directly by the next command. However, PAY ATTENTION to the
following. I dont yet know if its because of a bug or due to some limitation, but the fact is that the
following and the previous commands only give the same result if -E1 is used. For higher powers of
bathymetry in Parker expansion, only the above example seams to give the correct result.
gmt gravfft bat.grd -Gmodel.grd -T7000/2700/3300/1035 -Z9000 -E1
And what would be the geoid anomaly produced by a load at 50 km depth, below a region whose
bathymetry is given by bat.grd, a Moho at 9 km depth and the same densities as before?
gmt gravfft topo.grd -Gswell_geoid.grd -T7000/2700/3300/1035 -Fg -Z9000/50000 -S E1
404
To compute the admittance between the topo.grd bathymetry and faa.grd free-air anomaly grid using the
elastic plate model of a crust of 6 km mean thickness with 10 km effective elastic thickness in a region
of 3 km mean water depth:
gmt gravfft topo.grd faa.grd -It -T10000/2700/3300/1035 -Z9000
To compute the admittance between the topo.grd bathymetry and geoid.grd geoid grid with the loading
from below (LFB) model with the same as above and sub-surface load at 40 km, but assuming now the
grids are in geographic and we want wavelengths instead of frequency:
gmt gravfft topo.grd geoid.grd -Ibw -T10000/2700/3300/1035 -Z9000/40000 -fg
To compute the gravity theoretical admittance of a LFB along a 2000 km long profile using the same
parameters as above
gmt gravfft -C400/5000/3000/b -T10000/2700/3300/1035 -Z9000/40000
2.19.10 References
Luis, J.F. and M.C. Neves. 2006, The isostatic compensation of the Azores Plateau: a 3D
admittance and coherence analysis. J. Geothermal Volc. Res. Volume 156, Issues 1-2, Pages
10-22, http://dx.doi.org/10.1016/j.jvolgeores.2006.03.010 Parker, R. L., 1972, The rapid calculation of potential anomalies, Geophys. J., 31, 447-455. Wessel. P., 2001, Global distribution of
seamounts inferred from gridded Geosat/ERS-1 altimetry, J. Geophys. Res., 106(B9), 19,431-19,441,
http://dx.doi.org/10.1029/2000JB000083
2.20 grdflexure
grdflexure - Compute flexural deformation of 3-D surfaces for various rheologies
2.20.1 Synopsis
grdflexure topogrd -Drm/rl[/ri]/rw -ETe[u] -Goutgrid [ -ANx/Ny/Nxy ] [ -Cppoisson ] [ -CyYoung ] [
-Fnu_a[/h_a/nu_m] ] [ -Llist ] [ -N[f|q|s|nx/ny][+a|d|h|l][+e|n|m][+twidth][+w[suffix]][+z[p]] [ -Sbeta ]
[ -Tt0[u][/t1[u]/dt[u]|file] |n][+l] ] [ -V[level] ] [ -Wwd] [ -Zzm] [ -fg ]
Note: No space is allowed between the option flag and the associated arguments.
2.20.2 Description
grdflexure computes the flexural response to loads using a range of user-selectable rheologies. User may
select from elastic, viscoelastic, or firmoviscous (with one or two viscous layers). Temporal evolution
can also be modeled by providing incremental load grids and specifying a range of model output times.
2.20. grdflexure
405
406
2.20. grdflexure
407
2.20.7 Considerations
netCDF COARDS grids will automatically be recognized as geographic. For other grids geographical
grids were you want to convert degrees into meters, select -fg. If the data are close to either pole, you
should consider projecting the grid file onto a rectangular coordinate system using grdproject.
2.20.9 Examples
To compute elastic plate flexure from the load topo.nc, for a 10 km thick plate with typical densities, try
gmt grdflexure topo.nc -Gflex.nc -E10k -D2700/3300/1035
To compute the firmoviscous response to a series of incremental loads given by file name and load time
in the table l.lis at the single time 1 Ma using the specified rheological values, try
gmt grdflexure -T1M =l.lis -D3300/2800/2800/1000 -E5k -Gflx/smt_fv_%03.1f_%s.nc -F2e20 -Nf+a
2.20.10 References
Cathles, L. M., 1975, The viscosity of the earths mantle, Princeton University Press.
Wessel. P., 2001, Global distribution of seamounts inferred from gridded Geosat/ERS-1 altimetry, J.
Geophys. Res., 106(B9), 19,431-19,441, http://dx.doi.org/10.1029/2000JB000083
408
2.21 grdgravmag3d
grdgravmag3d - Compute the gravity effect of a grid by the method of Okabe
2.21.1 Synopsis
grdgravmag3d grdfile_top [grdfile_bot] [ -Cdensity ] [ -Ethick ] [ -Fxy_file ] [ -Goutgrid ] [ -H<...> ]
[ -Iincrement ] [ -Lz_obs ] [ -Q[nn_pad]|[pad_dist]|[<w/e/s/n>] ] [ -Rregion ] [ -Sradius ] [ -V[level] ] [
-Zlevel[b|t] ] [ -fg ] [ -x+a|n|-n ]
Note: No space is allowed between the option flag and the associated arguments.
2.21.2 Description
grdgravmag3d will compute the gravity anomaly of a body described by one or (optionally) two grids
The output can either be along a given set of xy locations or on a grid. This method is not particularly
fast but allows computing the anomaly of arbitrarily complex shapes.
2.21. grdgravmag3d
409
410
2.21.6 Examples
Suppose you want to compute the gravity effect of the phantom Sandy Island together with its not
phantom seamount
gmt grdgravmag3d sandy_bat.grd -C1700 -Z-4300 -fg -I1m -Gsandy_okb.grd -V
To compute the vertical component due to a magnetization stored in mag.grd over a zone defined by the
surface bat.grd, using variable declination and inclination provided the the IGRF and using 4 processors,
do:
gmt grdgravmag3d bat.grd -E10000 -Gcomp_Z.grd -Hz -H+n -H+mmag.grd -x4 -V -S50
2.21.8 Reference
Okabe, M., Analytical expressions for gravity anomalies due to polyhedral bodies and translation into
magnetic anomalies, Geophysics, 44, (1979), p 730-741.
2.22 grdredpol
grdredpol - Compute the Continuous Reduction To the Pole, AKA differential RTP.
2.22. grdredpol
411
2.22.1 Synopsis
grdredpol anom_grd -Grtp_grd [ -Cdec/dip] [ -Eiinc_grd] [ -Eddec_grd] [ -F<m/n>] [ -Mm|r] [ -N ]
[ -Wwin_width] [ -V[level] ] [ -Tyear ] [ -Zfiltergrd ] [ -V[level] ] [ -nflags ]
Note: No space is allowed between the option flag and the associated arguments.
2.22.2 Description
grdredpol will take a .nc file with a magnetic anomaly and compute the reduction to the pole (RTP)
anomaly. This anomaly is the one that would have been produce if the bodies were magnetized vertically and the anomalies were observed at the geomagnetic pole. Standard RTP procedure assumes the
direction of magnetization to be uniform throughout the causative body, and the geomagnetic field to be
uniform in direction throughout the study region. Although these assumptions are reasonable for small
areas, they do not hold for large areas.
In the method used here computations are carried out in both the frequency and the space domains. The
idea is that a large area may be decomposed in small size windows where both the ambient field and
the magnetization vector change by a very small amount. Inside each of those windows, or bins, a set of
filter coefficients are calculate and reconstruct for each individual point the component filter using a first
order Taylor series expansion.
412
2.22.6 Examples
Suppose that anom.grd is a file with the magnetic anomaly reduced to the 2010 epoch and that the
dec.grd and dip.grd contain the magnetization declination and inclination respectively for an area that
encloses that of the anom.grd, compute the RTP using bins of 2 degrees and a filter of 45 coefficients.
gmt grdredpol anom.grd -Grtp.grd -W2 -F45/45 -T2010 -Edec.grd/dip.grd -V
To compute the same RTP but now with the field and magnetization vectors collinear and computed
from IGRF :
gmt grdredpol anom.grd -Grtp.grd -W2 -F45/45 -T2010 -V
2.22.7 Reference
Luis, J.L. and Miranda, J.M. (2008), Reevaluation of magnetic chrons in the North Atlantic between
35N and 47N: Implications for the formation of the Azores Triple Junction and associated plateau. JGR,
VOL. 113, B10105, doi:10.1029/2007JB005573
2.23 grdseamount
grdseamount - Compute synthetic seamount (Gaussian, parabolic, cone, disc, circular or elliptical)
bathymetry
2.23.1 Synopsis
grdseamount [ intable ] -Iincrement -Rregion [ -A[out/in] ] [ -Cc|d|g|p ] [ -D[unit] ] [ -E ] [ F[flattening] ] [ -Ggrdfile ] [ -L[cut] ] [ -Mlist ] [ -Nnorm ] [ -Qbmode/qmode ] [ -Sscale ] [ Tt0[u][/t1[u]/dt[u]|n][+l] ] [ -Zlevel ] [ -V[level] ] [ -bibinary ] [ -fg ] [ -iflags ] [ -r ]
Note: No space is allowed between the option flag and the associated arguments.
2.23.2 Description
grdseamount will compute the combined shape of multiple synthetic seamounts given their individual
shape parameters. We read a list with seamount locations and sizes and can evaluate either Gaussian,
parabolic, conical, or disc shapes, which may be circular or elliptical, and optionally truncated. Various
scaling options are available to modify the result, including an option to add in a background depth (more
complicated backgrounds may be added via grdmath). The input must contain lon, lat, radius, height
for each seamount. For elliptical features (-E) we expect lon, lat, azimuth, semi-major, semi-minor,
2.23. grdseamount
413
height instead. If flattening is specified (-F) with no value appended then a final column with flattening
is expected (cannot be used for plateaus). For temporal evolution of topography the -T option may be
used, in which case the data file must have two final columns with the start and stop time of seamount
construction. In this case you may choose to write out a cumulative shape or just the increments produced
by each time step (see -Q).
414
-Qbmode/qmode Only to be used in conjunction with -T. Append two different modes settings: The
bmode determines how we construct the surface. Specify c for cumulative volume through time,
or i for incremental volume added for each time slice. The qmode determines the volume flux
curve. Give g for a Gaussian volume flux history or l for a linear volume flux history between the
start and stop times of each feature.
-Sscale Sets optional scale factor for radii [1].
-Tt0[u][/t1[u]/dt[u]|n][+l] Specify t0, t1, and time increment (dt) for sequence of calculations [Default
is one step, with no time dependency]. For a single specific time, just give start time t0. The unit
is years; append k for kyr and M for Myr. For a logarithmic time scale, append +l and specify n
steps instead of dt. Alternatively, give a file with the desired times in the first column (these times
may have individual units appended, otherwise we assume year). Note that the grid for t0 (if a
range is given) is not written as it is zero and marks the start of the building history.
-Zlevel Set the background depth [0].
-bi[ncols][t] (more ...) Select native binary input. [Default is 4 input columns].
-fg Geographic grids (dimensions of longitude, latitude) will be converted to km via a Flat Earth
approximation using the current ellipsoid parameters.
-h[i|o][n][+c][+d][+rremark][+rtitle] (more ...) Skip or produce header record(s). Not used with binary
data.
-icols[l][sscale][ooffset][,...] (more ...) Select input columns (0 is first column).
-V[level] (more ...) Select verbosity level [c].
-r (more ...) Set pixel node registration [gridline].
-:[i|o] (more ...) Swap 1st and 2nd column on input and/or output.
-^ or just - Print a short message about the syntax of the command, then exits (NOTE: on Windows use
just -).
-+ or just + Print an extensive usage (help) message, including the explanation of any module-specific
option (but not the GMT common options), then exits.
-? or no arguments Print a complete usage (help) message, including the explanation of options, then
exits.
2.23.5 Units
For map distance unit, append unit d for arc degree, m for arc minute, and s for arc second, or e for
meter [Default], f for foot, k for km, M for statute mile, n for nautical mile, and u for US survey foot.
By default we compute such distances using a spherical approximation with great circles. Prepend - to
a distance (or the unit is no distance is given) to perform Flat Earth calculations (quicker but less
accurate) or prepend + to perform exact geodesic calculations (slower but more accurate).
2.23.6 Examples
To compute the incremental loads from two elliptical, truncated Gaussian seamounts being constructed
from 3 Ma to 2 Ma and 2.8 M to 1.9 Ma using a linear volumetric production rate, and output an
incremental grid every 0.1 Myr from 3 Ma to 1.9 Ma, we can try:
2.23. grdseamount
415
2.24 talwani2d
talwani2d - Compute geopotential anomalies over 2-D bodies by the method of Talwani
2.24.1 Synopsis
talwani2d [ modeltable ] [ -A ] [ -Drho ] ] [ -Ff|n|v ] [ -M[h][v] ] [ -Ntrackfile ] [ -Tminmax/inc ] [
-Zlevel[ymin/ymax] ] [ -V[level] ] [ -bibinary ] [ -iflags ] [ -oflags ] [ -x[[-]n] ]
Note: No space is allowed between the option flag and the associated arguments.
2.24.2 Description
talwani2d will read the multi-segment modeltable from file or standard input. This file contains crosssections of one or more 2-D bodies, with one polygon per segment. The segment header must contain the
parameter rho, which states the the density of this body (individual body densities may be overridden by
a fixed constant density contrast given via -D). We can compute anomalies on an equidistant lattice (by
specifying a lattice with -T) or provide arbitrary output points specified in a file via -N. Choose between
free-air anomalies, vertical gravity gradient anomalies, or geoid anomalies. Options are available to
control axes units and direction.
416
-Ntrackfile Specifies locations where we wish to compute the predicted value. When this option is used
you cannot use -T to set an equidistant lattice. The output data records are written to stdout.
-Tminmax/inc Specify an equidistant output lattice starting at x = min, with increments inc and ending
at x = max.
-Zlevel[ymin/ymax] Set observation level as a constant [0]. Optionally, and for gravity anomalies only,
append the finite extent limits of a 2.5-D body.
-bi[ncols][t] (more ...) Select native binary input. [Default is 2 input columns].
-h[i|o][n][+c][+d][+rremark][+rtitle] (more ...) Skip or produce header record(s). Not used with binary
data.
-icols[l][sscale][ooffset][,...] (more ...) Select input columns (0 is first column).
-ocols[,...] (more ...) Select output columns (0 is first column).
-V[level] (more ...) Select verbosity level [c].
-x[[-]n] (more ...) Limit number of cores used in multi-threaded algorithms (OpenMP required).
-:[i|o] (more ...) Swap 1st and 2nd column on input and/or output.
-^ or just - Print a short message about the syntax of the command, then exits (NOTE: on Windows use
just -).
-+ or just + Print an extensive usage (help) message, including the explanation of any module-specific
option (but not the GMT common options), then exits.
-? or no arguments Print a complete usage (help) message, including the explanation of options, then
exits.
2.24.5 Units
For map distance unit, append unit d for arc degree, m for arc minute, and s for arc second, or e for
meter [Default], f for foot, k for km, M for statute mile, n for nautical mile, and u for US survey foot.
By default we compute such distances using a spherical approximation with great circles. Prepend - to
a distance (or the unit is no distance is given) to perform Flat Earth calculations (quicker but less
accurate) or prepend + to perform exact geodesic calculations (slower but more accurate).
2.24.6 Examples
To compute the free-air anomalies on a grid over a 2-D body that has been contoured and saved to
body.txt, using 1.7 g/cm^3 as the density contrast, try
gmt talwani2d -T-200/200/2 body.txt -D1700 -Fg > 2dgrav.txt
To obtain the vertical gravity gradient anomaly along the track in crossing.txt for the same model, try
gmt talwani2d -Ncrossing.txt body.txt -D1700 -Fv > vgg_crossing.txt
2.24. talwani2d
417
2.24.7 Notes
1. The 2-D geoid anomaly is a logarithmic potential and thus has no natural reference level. We
simply remove the most negative (if density contrast is positive) or positive (if density contrast
is negative) computed value from all values, rendering the entire anomaly positive (or negative).
You can use gmtmath to change the zero level to suit your needs.
2.24.8 References
Chapman, M. E. (1979), Techniques for interpretation of geoid anomalies, J. Geophys. Res., 84(B8),
3793-3801. Talwani, M., J. L. Worzel, and M. Landisman (1959), Rapid gravity computations for twodimensional bodies with application to the Mendocino submarine fracture zone, J. Geophys. Res., 64,
49-59.
2.25 talwani3d
talwani3d - Compute geopotential anomalies over 3-D bodies by the method of Talwani
2.25.1 Synopsis
talwani3d [ modeltable ] [ -A ] [ -Drho ] ] [ -Ff|n|v ] [ -Ggrdfile ] [ -Iincrement ] [ -M[h][v] ] [ -Ntrackfile
] [ -Rregion ] [ -Zlevel|obsgrid ] [ -V[level] ] [ -bibinary ] [ -fg ] [ -iflags ] [ -oflags ] [ -r ] [ -x[[-]n] ]
Note: No space is allowed between the option flag and the associated arguments.
2.25.2 Description
talwani3d will read the multi-segment modeltable from file or standard input. This file contains contours
of a 3-D body at different z-levels, with one contour per segment. The segment header must contain the
parameters zlevel rho, which states the z contour level and the density of this slice (individual slice
densities may be overridden by a fixed density contrast given via -D). We can compute anomalies on an
equidistant grid (by specifying a new grid with -R and -I or provide an observation grid with elevations)
or at arbitrary output points specified via -N. Chose from free-air anomalies, vertical gravity gradient
anomalies, or geoid anomalies. Options are available to control axes units and direction.
and will be converted to the equivalent degrees longitude at the middle latitude of the region (the
conversion depends on PROJ_ELLIPSOID). If y_inc is given but set to 0 it will be reset equal to
x_inc; otherwise it will be converted to degrees latitude. All coordinates: If = is appended then the
corresponding max x (east) or y (north) may be slightly adjusted to fit exactly the given increment
[by default the increment may be adjusted slightly to fit the given domain]. Finally, instead of
giving an increment you may specify the number of nodes desired by appending + to the supplied
integer argument; the increment is then recalculated from the number of nodes and the domain.
The resulting increment value depends on whether you have selected a gridline-registered or pixelregistered grid; see App-file-formats for details. Note: if -Rgrdfile is used then the grid spacing
has already been initialized; use -I to override the values.
-R[unit]xmin/xmax/ymin/ymax[r] (more ...) Specify the region of interest.
2.25. talwani3d
419
-? or no arguments Print a complete usage (help) message, including the explanation of options, then
exits.
2.25.5 Units
For map distance unit, append unit d for arc degree, m for arc minute, and s for arc second, or e for
meter [Default], f for foot, k for km, M for statute mile, n for nautical mile, and u for US survey foot.
By default we compute such distances using a spherical approximation with great circles. Prepend - to
a distance (or the unit is no distance is given) to perform Flat Earth calculations (quicker but less
accurate) or prepend + to perform exact geodesic calculations (slower but more accurate).
2.25.6 Examples
To compute the free-air anomalies on a grid over a 3-D body that has been contoured and saved to
body.txt, using 1.7 g/cm^3 as the density contrast, try
gmt talwani3d -R-200/200/-200/200 -I2 -G3dgrav.nc body.txt -D1700 -Fg
To obtain the vertical gravity gradient anomaly along the track in crossing.txt for the same model, try
gmt talwani3d -Ncrossing.txt body.txt -D1700 -Fv > vgg_crossing.txt
Finally, the geoid anomaly along the same track in crossing.txt for the same model is returned by
gmt talwani3d -Ncrossing.txt body.txt -D1700 -Fn > n_crossing.txt
2.25.7 References
Talwani, M., and M. Ewing (1960), Rapid computation of gravitational attraction of three-dimensional
bodies of arbitrary shape, Geophysics, 25(203-225).
2.26 pssegy
pssegy - Plot a SEGY file on a map
2.26.1 Synopsis
pssegy SEGYfile -Jparameters -Rregion -Ddeviation -F[color] -W [ -Cclip ] [ -Eerror ] [ -I ] [ -K ] [
-Lnsamp ] [ -Mntrace ] [ -N ] [ -O ] [ -P ] [ -Q<mode><value> ] [ -Sheader ] [ -Tfilename ] [ -U[stamp]
] [ -V[level] ] [ -Xx_offset ] [ -Yy_offset ] [ -pflags ] [ -ttransp ]
Note: No space is allowed between the option flag and the associated arguments.
420
2.26.2 Description
pssegy reads a native (IEEE) format SEGY file and produces a PostScript image of the seismic data.
The imagemask operator is used so that the seismic data are plotted as a 1-bit deep bitmap in a single
(user-specified) color or gray shade, with a transparent background. The bitmap resolution is taken from
the current GMT defaults. The seismic traces may be plotted at their true locations using information
in the trace headers (in which case order of the traces in the file is not significant). Standard GMT
geometry routines are used so that in principle any map projection may be used, however it is likely
that the geographic projections will lead to unexpected results. Beware also that some parameters have
non-standard meanings.
Note that the order of operations before the seismic data are plotted is deviation*[clip]([bias]+[normalize](sample value)). Deviation determines how far in the plot coordinates a
[normalized][biased][clipped] sample value of 1 plots from the trace location.
The SEGY file should be a disk image of the tape format (i.e., 3200 byte text header, which is ignored,
400 byte binary reel header, and 240 byte header for each trace) with samples as native real*4 (IEEE
real on all the platforms to which I have access).
2.26. pssegy
421
-Cclip Sample value at which to clip data (clipping is applied to both positive and negative values).
-Eerror Allow error difference between requested and actual trace locations when using -T option.
-I Fill negative rather than positive excursions.
-K (more ...) Do not finalize the PostScript plot.
-L Override number of samples per trace in reel header (program attempts to determine number of
samples from each trace header if possible to allow for variable length traces).
-M Override number of traces specified in reel header. Program detects end of file (relatively) gracefully,
but this parameter limits number of traces that the program attempts to read.
-N Normalize trace by dividing by rms amplitude over full trace length.
-O (more ...) Append to existing PostScript plot.
-P (more ...) Select Portrait plot orientation.
-Q<mode><value>
Can be used to change 5 different settings depending on mode: -Qbbias to bias scaled traces
(-Qb-0.1 subtracts 0.1 from values).
-Qidpi sets the dots-per-inch resolution of the image [300].
-Quredvel to apply reduction velocity (negative value removes reduction already present).
-Qxmult to multiply trace locations by mult.
-Qydy to override sample interval in SEGY reel header.
-Sheader Read trace locations from trace headers: header is either c for CDP, o for offset, or bnum to
read a long starting at byte num in the header (first byte corresponds to num = 0). Default has
location given by trace number.
-Tfilename Plot only traces whose location corresponds to a list given in filename. Order in which traces
are listed is not significant - the entire space is checked for each trace.
-U[just/dx/dy/][c|label] (more ...) Draw GMT time stamp logo on plot.
-V[level] (more ...) Select verbosity level [c].
-X[a|c|f|r][x-shift[u]]
-Y[a|c|f|r][y-shift[u]] (more ...) Shift plot origin.
-Z Do not plot traces with zero rms amplitude.
-p[x|y|z]azim/elev[/zlevel][+wlon0/lat0[/z0]][+vx0/y0] (more ...) Select perspective view.
-t[transp] (more ...) Set PDF transparency level in percent.
-^ or just - Print a short message about the syntax of the command, then exits (NOTE: on Windows use
just -).
-+ or just + Print an extensive usage (help) message, including the explanation of any module-specific
option (but not the GMT common options), then exits.
-? or no arguments Print a complete usage (help) message, including the explanation of options, then
exits.
422
2.26.5 Examples
To plot the SEGY file wa1.segy with normalized traces plotted at true offset locations, clipped at +-3
and with wiggle trace and positive variable area shading in black, use
gmt pssegy wa1.segy -JX5i/-5i -R0/100/0/10 -D1 -C3 -N -So -W -Fblack > segy.ps
To plot the SEGY file wa1.segy with traces plotted at true cdp*0.1, clipped at +/-3, with bias -1 and
negative variable area shaded red, use
gmt pssegy wa1.segy -JX5i/-5i -R0/100/0/10 -D1 -C3 -Sc -Qx0.1 -Fred -Qb-1 -I >
segy.ps
2.27 pssegyz
pssegyz - Create imagemasked postscript from SEGY file
2.27.1 Synopsis
pssegyz SEGYfile -Jparameters -Jz|Zparameters -Rwest/east/south/north[/zmin/zmax][r] -Ddeviation F[color] -W [ -Cclip ] [ -I ] [ -K ] [ -Lnsamp ] [ -Mntrace ] [ -N ] [ -O ] [ -P ] [ -Q<mode><value> ] [
-Sheader_x/header_y ] [ -U[stamp] ] [ -V[level] ] [ -Xx_offset ] [ -Yy_offset ] [ -Z ] [ -pflags ] [ -ttransp
]
Note: No space is allowed between the option flag and the associated arguments.
2.27.2 Description
pssegyz reads a native (IEEE) format SEGY file and produces a PostScript image of the seismic data.
The imagemask operator is used so that the seismic data are plotted as a 1-bit deep bitmap in a single
(user-specified) color or gray shade, with a transparent background. The bitmap resolution is taken from
the current GMT defaults. The seismic traces may be plotted at their true locations using information
in the trace headers (in which case order of the traces in the file is not significant). Standard GMT
geometry routines are used so that in principle any map projection may be used, however it is likely
that the geographic projections will lead to unexpected results. Beware that a couple of the options for
pssegy are not available in pssegyz.
Note that the order of operations before the seismic data are plotted is deviation*[clip]([bias]+[normalize](sample value)). Deviation determines how far in the plot coordinates a
[normalized][biased][clipped] sample value of 1 plots from the trace location.
The SEGY file should be a disk image of the tape format (i.e., 3200 byte text header, which is ignored,
400 byte binary reel header, and 240 byte header for each trace) with samples as native real*4 (IEEE
real on all the platforms to which I have access).
2.27. pssegyz
423
424
2.27.5 Examples
To plot the SEGY file wa1.segy with normalized traces plotted at true offset locations, clipped at +/-3
and with wiggle trace and positive variable area shading in black, use
gmt pssegyz wa1.segy -JX5i/-5i -D1 -Jz0.05i -E180/5 -R0/100/0/10/0/10 \
-C3 -N -So -W -Fblack > segy.ps
2.27.6 Bugs
Variable area involves filling four-sided figures of distressing generality. I know that some of the more
complex degenerate cases are not dealt with correctly or at all; the incidence of such cases increases as
viewing angles become more oblique, and particularly as the viewing elevation increases. Wiggle-trace
plotting is not affected.
2.27. pssegyz
425
2.28 segy2grd
segy2grd - Converting SEGY data to a GMT grid
2.28.1 Synopsis
segy2grd
segyfile
-Ggrdfile
-Iincrement
-Rregion
[
-A[n|z]
]
[
Dxname/yname/zname/scale/offset/title/remark ] [ -L[nsamp] ] [ -M[ntraces] ] [ -Nnodata ] [
-Q<mode><value> ] [ -S[header] ] [ -V[level] ] [ -bibinary ] [ -:[i|o] ]
Note: No space is allowed between the option flag and the associated arguments.
2.28.2 Description
segy2grd reads an IEEE SEGY file and creates a binary grid file. Either a simple mapping (equivalent
to xyz2grd -Z) or a more complicated averaging where a particular grid cell includes values from more
than one sample in the SEGY file can be done. segy2grd will report if some of the nodes are not filled
in with data. Such unconstrained nodes are set to a value specified by the user [Default is NaN]. Nodes
with more than one value will be set to the average value.
426
2.28.5 Examples
To create a grid file from an even spaced SEGY file test.segy, try
gmt segy2grd test.segy -I0.1/0.1 -Gtest.nc -R198/208/18/25 -V
Note that this will read in 18-25s (or km) on each trace, but the first trace will be assumed to be at X=198
To create a grid file from the SEGY file test.segy, locating traces according to the CDP number, where
there are 10 CDPs per km and the sample interval is 0.1, try
gmt segy2grd test.segy -Gtest.nc -R0/100/0/10 -I0.5/0.2 -V -Qx0.1 -Qy0.1
Because the grid interval is larger than the SEGY file sampling, the individual samples will be averaged
in bins
2.28. segy2grd
427
2.29 backtracker
backtracker - Generate forward and backward flowlines and hotspot tracks
2.29.1 Synopsis
backtracker [ table ] -Erot_file|lon/lat/angle [ -A[young/old] ] [ -Df|b ] [ -Fdrift.txt ] [ -Lf|bstep ] [ Nupper_age ] [ -Qfixed_age ] [ -Sfilestem ] [ -Tzero_age ] [ -V[level] ] [ -W[a|t] ] [ -bbinary ] [ -dnodata
] [ -hheaders ] [ -iflags ] [ -oflags ] [ -:[i|o] ]
Note: No space is allowed between the option flag and the associated arguments.
2.29.2 Description
backtracker reads (longitude, latitude, age) positions from infiles [or standard input] and computes rotated (x,y,t) coordinates using the specified rotation parameters. It can either calculate final positions [Default] or create a sampled track (flowline or hotspot track) between the initial and final positions. The former mode allows additional data fields after the first 3 columns which must have (longitude,latitude,age).
See option -: on how to read (latitude,longitude,age) files.
-A[young/old] Used in conjunction with -Lb|f to limit the track output to those sections whose predicted
ages lie between the specified young and old limits. If -LB|F is used instead then the limits apply
to the stage ids (id 1 is the youngest stage). If no limits are specified then individual limits for each
record are expected in columns 4 and 5 of the input file.
-Df|b Set the direction to go: -Df will go backward in time (from younger to older positions), while
-Db will go forward in time (from older to younger positions) [Default]. Note: For -Db you are
specifying the age at the given location, whereas for -Df you are not; instead you specify the age
at the reconstructed point.
-Fdrift.txt Supply a file with lon, lat, age records that describe the history of hotspot motion for the
current hotspot. The reconstructions will only use the 3rd data input column (i.e., the age) to
obtain the location of the hotspot at that time, via an interpolation of the hotspot motion history.
This adjusted location is then used to reconstruct the point or path [No drift].
-Lf|bstep Specify a sampled path between initial and final position: -Lf will draw particle flowlines,
while -Lb will draw backtrack (hotspot track) paths. Append sampling interval in km. If step < 0
then only the rotation times will be returned. When -LF or -LB is used, the third output column
will contain the stage id (1 is youngest) [Default is along-track predicted ages]. You can control
the direction of the paths by using -D.
-Nupper_age Set the maximum age to extend the oldest stage rotation back in time [Default is no
extension].
-Qfixed_age Assign a fixed age to all positions. Only lon, lat input is expected [Default expects longitude, latitude, age]. Useful when the input are points defining isochrons.
-Sfilestem When -L is set, the tracks are normally written to stdout as a multisegment file. Specify a
filestem to have each track written to filestem.#, where # is the track number. The track number is
also copied to the 4th output column.
-Tzero_age Set the current time [Default is 0 Ma].
-V[level] (more ...) Select verbosity level [c].
-W[a|t] Rotates the given input (lon,lat,t) and calculates the confidence ellipse for the projected point.
The input point must have a time coordinate that exactly matches a particular total reconstruction
rotation time, otherwise the point will be skipped. Append t or a to output time or angle, respectively, after the projected lon, lat. After these 2-3 items, we write azimuth, major, minor (in km)
for the 95% confidence ellipse. See -D for the direction of rotation.
-bi[ncols][t] (more ...) Select native binary input. [Default is 3 input columns].
-bo[ncols][type] (more ...) Select native binary output. [Default is same as input].
-d[i|o]nodata (more ...) Replace input columns that equal nodata with NaN and do the reverse on output.
-h[i|o][n][+c][+d][+rremark][+rtitle] (more ...) Skip or produce header record(s).
-icols[l][sscale][ooffset][,...] (more ...) Select input columns (0 is first column).
-ocols[,...] (more ...) Select output columns (0 is first column).
-:[i|o] (more ...) Swap 1st and 2nd column on input and/or output.
-^ or just - Print a short message about the syntax of the command, then exits (NOTE: on Windows use
just -).
2.29. backtracker
429
-+ or just + Print an extensive usage (help) message, including the explanation of any module-specific
option (but not the GMT common options), then exits.
-? or no arguments Print a complete usage (help) message, including the explanation of options, then
exits.
2.29.6 Examples
To backtrack the (x,y,t) points in the file seamounts.txt to their origin (presumably the hotspot), using
the DC85.txt Euler poles, run
gmt backtracker seamounts.txt -Db -EDC85.txt > newpos.txt
To project flowlines forward from the (x,y,t) points stored in several 3-column, binary, double precision
files, run
gmt backtracker points.\* -Df -EDC85.txt -Lf25 -bo -bi3 > lines.b
This file can then be plotted with psxy. To compute the predicted Hawaiian hotspot track from 0 to
80 Ma every 1 Ma, given a history of hotspot motion file (HIdrift.txt) and a set of total reconstruction
rotations for the plate (PAC_APM.txt), try
echo 204 19 80 | gmt backtracker -Df -EPAC_APM.txt -Lb1 > path.txt
2.29.7 Notes
GMT distributes the EarthByte rotation model Global_EarthByte_230-0Ma_GK07_AREPS.rot. To use
an alternate rotation file, create an environmental parameters named GPLATES_ROTATIONS that
points to an alternate rotation file.
2.29.9 References
Wessel, P., 1999, Hotspotting tools released, EOS Trans. AGU, 80 (29), p. 319.
2.30 grdpmodeler
grdpmodeler - Evaluate a plate motion model on a geographic grid
430
2.30.1 Synopsis
grdpmodeler agegrdfile -Erot_file -Sflags [ -Fpolygonfile ] [ -Goutgrdfile ] [ -Tage ] [ -V[level] ] [
-bbinary ] [ -dnodata ] [ -hheaders ] [ -:[i|o] ]
Note: No space is allowed between the option flag and the associated arguments.
2.30.2 Description
grdpmodeler reads a geographical age grid and a plate motion model and evaluates one of several model
predictions. Optionally, the user may supply a clipping polygon in multiple-segment format; then, only
the part of the grid inside the polygon is used to determine the model prediction; the remainder of the
grid is set to NaN.
2.30. grdpmodeler
431
stage, vel, omega, dlon, dlat, lon, lat. If the -G option is not used then we create no grids and
instead write lon, lat, age, predictions records to standard output.
-Tage Use a fixed age for model evaluation (i.e., override the ages in the age grid). This lets you evaluate
the model at a snapshot in time.
-V[level] (more ...) Select verbosity level [c].
-bi[ncols][t] (more ...) Select native binary input. [Default is 2 input columns].
-d[i|o]nodata (more ...) Replace input columns that equal nodata with NaN and do the reverse on output.
-h[i|o][n][+c][+d][+rremark][+rtitle] (more ...) Skip or produce header record(s).
-^ or just - Print a short message about the syntax of the command, then exits (NOTE: on Windows use
just -).
-+ or just + Print an extensive usage (help) message, including the explanation of any module-specific
option (but not the GMT common options), then exits.
-? or no arguments Print a complete usage (help) message, including the explanation of options, then
exits.
2.30.6 Examples
We will use a grid with Pacific crust ages (pac_age.nc), a plate motion model (Pac_APM.d), and a
polygon that contains the outline of the present Pacific plate (pac_clip_path.d). To evaluate the plate
motion azimuths at the present time for the Pacific, try
gmt grdpmodeler pac_age.nc -EPac_APM.d -V -Fpac_clip_path.d \
-Gpac_dir_0.nc -Sa -T0
To determine the changes in latitude since crust formation for the entire Pacific, try
gmt grdpmodeler pac_age.nc -EPac_APM.d -V -Fpac_clip_path.d \
-Gpac_dlat.nc -Sy
To determine the plate motion velocities in effect when the Pacific crust was formed, try
gmt grdpmodeler pac_age.nc -EPac_APM.d -V -Fpac_clip_path.d \
-Gpac_vel.nc -Sv
To determine how far the crust has moved since formation, try
gmt grdpmodeler pac_age.nc -EPac_APM.d -V -Fpac_clip_path.d \
-Gpac_dist.nc -Sd
432
To repeat the same exercise but save output lon,lat,age,xorigin,yorigin to a table, use
gmt grdpmodeler pac_age.nc -EPac_APM.d -V -Fpac_clip_path.d -SXY > origin.txt
2.30.7 Notes
GMT distributes the EarthByte rotation model Global_EarthByte_230-0Ma_GK07_AREPS.rot. To use
an alternate rotation file, create an environmental parameters named GPLATES_ROTATIONS that
points to an alternate rotation file.
2.31 grdrotater
grdrotater - Finite rotation reconstruction of geographic grid
2.31.1 Synopsis
grdrotater ingrdfile -Erot_file|lon/lat/angle -Goutgrdfile [ -Drotoutline ] [ -Fpolygonfile ] [ -N ] [ Rregion ] [ -S ] [ -Tages ] [ -V[level] ] [ -bbinary ] [ -dnodata ] [ -hheaders ] [ -nflags ] [ -:[i|o] ]
Note: No space is allowed between the option flag and the associated arguments.
2.31.2 Description
grdrotater reads a geographical grid and reconstructs it given total reconstruction rotations. Optionally,
the user may supply a clipping polygon in multiple-segment format; then, only the part of the grid inside
the polygon is used to determine the reconstructed region. The outlines of the reconstructed region is
also returned provided the rotated region is not the entire globe.
433
e f ] which shows C made up of three row vectors. If the degrees of freedom (df ) in fitting the
rotation is 0 or not given it is set to 10000. Blank lines and records whose first column contains
# will be ignored. You may prepend a leading + to the filename to indicate you wish to invert the
rotations. Alternative 1: Give the filename composed of two plate IDs separated by a hyphen (e.g.,
PAC-MBL) and we will instead extract that rotation from the GPlates rotation database. We return
an error if the rotation cannot be found. Alternative 2: Specify lon/lat/angle, i.e., the longitude,
latitude, and opening angle (all in degrees and separated by /) for a single total reconstruction
rotation.
-Goutgrdfile Name of output grid. This is the grid with the data reconstructed according to the specified
rotation. If more than one reconstruction time is implied then outgrdfile must contain a C-format
specifier to format a floating point number (reconstruction time) to text.
434
-d[i|o]nodata (more ...) Replace input columns that equal nodata with NaN and do the reverse on output.
-h[i|o][n][+c][+d][+rremark][+rtitle] (more ...) Skip or produce header record(s).
-:[i|o] (more ...) Swap 1st and 2nd column on input and/or output.
-n[b|c|l|n][+a][+bBC][+c][+tthreshold] (more ...) Select interpolation mode for grids.
-^ or just - Print a short message about the syntax of the command, then exits (NOTE: on Windows use
just -).
-+ or just + Print an extensive usage (help) message, including the explanation of any module-specific
option (but not the GMT common options), then exits.
-? or no arguments Print a complete usage (help) message, including the explanation of options, then
exits.
2.31.7 Examples
To rotate the data defined by grid topo.nc and the polygon outline clip_path.d, using a total reconstruction
rotation with pole at (135.5, -33.0) and a rotation angle of 37.3 degrees and bicubic interpolation, try
gmt grdrotater topo.nc -E135.5/-33/37.3 -V -Fclip_path.d -Grot_topo.nc > rot_clip_
path.d
To rotate the entire grid faa.nc back to 32 Ma using the rotation file rotations.txt and a bilinear interpolation, try
gmt grdrotater faa.nc -Erotations.txt -T32 -V -Grot_faa.nc -nl > rot_faa_path.d
To just see how the outline of the grid large.nc will plot after the same rotation, try
gmt grdrotater large.nc -Erotations.txt -T32 -V -S \| psxy -Rg -JH180/6i -B30 -W0.
5p \| gv -
To rotate the grid topo.nc back to 100 Ma using the rotation file rotations.txt and request a reconstruction
every 10 Myr, saving both grids and outlines to filenames that derive from templates, try
2.31. grdrotater
435
Let say you have rotated gridA.nc and gridB.nc, restricting each rotation to nodes inside polygons
polyA.d and polyB.d, respectively, using rotation A = (123W,22S,16,4) and rotation B = (108W, 16S,
-14.5), yielding rotated grids rot_gridA.nc and rot_gridB.nc. To determine the region of overlap between
the rotated grids, we use grdmath:
gmt grdmath 1 rot_gridA.nc ISNAN SUB 1 rot_gridB.nc ISNAN SUB 2 EQ = overlap.nc
The grid overlap.nc now has 1s in the regions of overlap and 0 elsewhere. You can use it as a mask or
use grdcontour -D to extract a polygon (i.e., a contour).
2.31.8 Notes
GMT distributes the EarthByte rotation model Global_EarthByte_230-0Ma_GK07_AREPS.rot. To use
an alternate rotation file, create an environmental parameters named GPLATES_ROTATIONS that
points to an alternate rotation file.
2.32 grdspotter
grdspotter - Create CVA image from a gravity or topography grid
2.32.1 Synopsis
grdspotter [grdfile] -Erotfile -GCVAgrid -Iincrement -Rregion [ -Aagegrid ] [ -DDIgrid ] [ -LIDgrid ]
[ -M ] [ -Nupper_age ] [ -PPAgrid ] [ -QIDinfo ] [ -S ] [ -Tt|ufixed_val ] [ [ -V[level] ] [ -Wn_try ]] [
-Zz_min[/z_max[/z_inc]] ] [ -r ]
Note: No space is allowed between the option flag and the associated arguments.
2.32.2 Description
grdspotter reads a grid file with residual bathymetry or gravity and calculates flowlines from each node
that exceeds a minimum value using the specified rotations file. These flowlines are then convolved with
the volume of the prism represented by each grid node and added up to give a Cumulative Volcano
Amplitude grid (CVA).
436
-Erotfile Give file with rotation parameters. This file must contain one record for each rotation; each
record must be of the following format:
lon lat tstart [tstop] angle [ khat a b c d e f g df ]
where tstart and tstop are in Myr and lon lat angle are in degrees. tstart and tstop are the ages of
the old and young ends of a stage. If tstop is not present in the record then a total reconstruction
rotation is expected and tstop is implicitly set to 0 and should not be specified for any of the
records in the file. If a covariance matrix C for the rotation is available it must be specified in
a format using the nine optional terms listed in brackets. Here, C = (g/khat)*[ a b d; b c e; d
e f ] which shows C made up of three row vectors. If the degrees of freedom (df ) in fitting the
rotation is 0 or not given it is set to 10000. Blank lines and records whose first column contains
# will be ignored. You may prepend a leading + to the filename to indicate you wish to invert the
rotations. Alternatively, give the filename composed of two plate IDs separated by a hyphen (e.g.,
PAC-MBL) and we will instead extract that rotation from the GPlates rotation database. We return
an error if the rotation cannot be found.
-G Specify name for output CVA grid file.
-Ixinc[unit][=|+][/yinc[unit][=|+]] x_inc [and optionally y_inc] is the grid spacing. Optionally, append
a suffix modifier. Geographical (degrees) coordinates: Append m to indicate arc minutes or s
to indicate arc seconds. If one of the units e, f, k, M, n or u is appended instead, the increment
is assumed to be given in meter, foot, km, Mile, nautical mile or US survey foot, respectively,
and will be converted to the equivalent degrees longitude at the middle latitude of the region (the
conversion depends on PROJ_ELLIPSOID). If y_inc is given but set to 0 it will be reset equal to
x_inc; otherwise it will be converted to degrees latitude. All coordinates: If = is appended then the
corresponding max x (east) or y (north) may be slightly adjusted to fit exactly the given increment
[by default the increment may be adjusted slightly to fit the given domain]. Finally, instead of
giving an increment you may specify the number of nodes desired by appending + to the supplied
integer argument; the increment is then recalculated from the number of nodes and the domain.
The resulting increment value depends on whether you have selected a gridline-registered or pixelregistered grid; see App-file-formats for details. Note: if -Rgrdfile is used then the grid spacing
has already been initialized; use -I to override the values.
-R[unit]west/east/south/north[/zmin/zmax][r] west, east, south, and north specify the region of interest, 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 w/e/s/n. The two
shorthands -Rg and -Rd stand for global domain (0/360 and -180/+180 in longitude respectively,
with -90/+90 in latitude). Alternatively for grid creation, give Rcodelon/lat/nx/ny, where code is
a 2-character combination of L, C, R (for left, center, or right) and T, M, B for top, middle, or
bottom. e.g., BL for lower left. This indicates which point on a rectangular region the lon/lat coordinate refers to, and the grid dimensions nx and ny with grid spacings via -I is used to create
the corresponding region. Alternatively, specify the name of an existing grid file and the -R settings (and grid spacing, if applicable) are copied from the grid. Using -Runit expects projected
(Cartesian) coordinates compatible with chosen -J and we inversely project to determine actual
rectangular geographic region. For perspective view (-p), optionally append /zmin/zmax. In case
of perspective view (-p), a z-range (zmin, zmax) can be appended to indicate the third dimension.
This needs to be done only when using the -Jz option, not when using only the -p option. In the
latter case a perspective view of the plane is plotted, with no third dimension.
2.32. grdspotter
437
438
2.32.6 Examples
To create a CVA image from the Pacific topography grid Pac_res_topo.nc, using the DC85.d Euler poles,
and only output a grid for the specified domain, run
gmt grdspotter Pac_res_topo.nc -EDC85.d -GCVA.nc -R190/220/15/25 -I2m -N145 -Tt -V
2.32.7 Notes
GMT distributes the EarthByte rotation model Global_EarthByte_230-0Ma_GK07_AREPS.rot. To use
an alternate rotation file, create an environmental parameters named GPLATES_ROTATIONS that
points to an alternate rotation file.
2.32.9 References
Wessel, P., 1999, Hotspotting tools released, EOS Trans. AGU, 80 (29), p. 319.
Wessel, P., 2008, Hotspotting: Principles and properties of a plate tectonic Hough transform, Geochem.
Geophys. Geosyst. 9(Q08004): doi:10.1029/2008GC002058.
2.33 hotspotter
hotspotter - Create CVA image from seamount locations
2.33.1 Synopsis
hotspotter [tables] -Erotfile -GCVAgrid -Iincrement -Rregion [ -Nupper_age ] [ -S ] [ -T ] [ -V[level] ]
[ -bibinary ] [ -dinodata ] [ -hheaders ] [ -iflags ] [ -oflags ] [ -:[i|o] ]
Note: No space is allowed between the option flag and the associated arguments.
2.33. hotspotter
439
2.33.2 Description
hotspotter reads (longitude, latitude, amplitude, radius, age) records from tables [or standard input]
and calculates flowlines using the specified stage or total reconstruction rotations. These flowlines are
convolved with the shape of the seamount (using a Gaussian shape given amplitude and radius = 6
sigma) and added up to give a Cumulative Volcano Amplitude grid (CVA). See option -: on how to read
(latitude,longitude,...) files.
440
bottom. e.g., BL for lower left. This indicates which point on a rectangular region the lon/lat coordinate refers to, and the grid dimensions nx and ny with grid spacings via -I is used to create
the corresponding region. Alternatively, specify the name of an existing grid file and the -R settings (and grid spacing, if applicable) are copied from the grid. Using -Runit expects projected
(Cartesian) coordinates compatible with chosen -J and we inversely project to determine actual
rectangular geographic region. For perspective view (-p), optionally append /zmin/zmax. In case
of perspective view (-p), a z-range (zmin, zmax) can be appended to indicate the third dimension.
This needs to be done only when using the -Jz option, not when using only the -p option. In the
latter case a perspective view of the plane is plotted, with no third dimension.
2.33. hotspotter
441
2.33.6 Examples
To create a CVA image from the Pacific (x,y,z,r,t) data in the file seamounts.d, using the DC85.d Euler
poles, run
gmt hotspotter seamounts.d -EDC85.d -GCVA.nc -R130/260/-66/60 -I10m -N145 -T -V
2.33.7 Notes
GMT distributes the EarthByte rotation model Global_EarthByte_230-0Ma_GK07_AREPS.rot. To use
an alternate rotation file, create an environmental parameters named GPLATES_ROTATIONS that
points to an alternate rotation file.
2.33.9 References
Wessel, P., 1999, Hotspotting tools released, EOS Trans. AGU, 80 (29), p. 319.
Wessel, P., 2008, Hotspotting: Principles and properties of a plate tectonic Hough transform, Geochem.
Geophys. Geosyst. 9(Q08004): doi:10.1029/2008GC002058.
2.34 originator
originator - Associate seamounts with nearest hotspot point sources
2.34.1 Synopsis
originator [ tables ] -E[+]rotfile -F[+]hs_file [ -Dd_km ] [ -L[flag] ] [ -Nupper_age ] [ -Qr/t ] [ -S[n_hs]
] [ -T ] [ -V[level] ] [ -Wmaxdist ] [ -Z ] [ -bibinary ] [ -dinodata ] [ -hheaders ] [ -iflags ] [ -:[i|o] ]
Note: No space is allowed between the option flag and the associated arguments.
2.34.2 Description
originator reads (longitude, latitude, height, radius, crustal_age) records from tables [or standard input]
and uses the given Absolute Plate Motion (APM) stage or total reconstruction rotation file and the
list of hotspot locations to determine the most likely origin (hotspot) for each seamount. It does so
by calculating flowlines back in time and determining the closest approach to all hotspots. The output
consists of the input records with four additional fields added for each of the n_hs closest hotspots. The
four fields are the hotspot id (e.g., HWI), the stage id of the flowline segment that came closest, the
pseudo-age of the seamount, and the closest distance to the hotspot (in km). See option -: on how to read
(latitude, longitude,height, radius, crustal_age) files.
442
443
-T Truncate seamount ages exceeding the upper age set with -N [no truncation].
-V[level] (more ...) Select verbosity level [c].
-Wmaxdist Only report those seamounts whose flowlines came within maxdist to any hotspot [Default
reports all seamounts].
-Z Use the hotspot ID number rather than the name tag in output records.
-bi[ncols][t] (more ...) Select native binary input. [Default is 5 input columns].
-dinodata (more ...) Replace input columns that equal nodata with NaN.
-V[level] (more ...) Select verbosity level [c].
-icols[l][sscale][ooffset][,...] (more ...) Select input columns (0 is first column).
-:[i|o] (more ...) Swap 1st and 2nd column on input and/or output.
-^ or just - Print a short message about the syntax of the command, then exits (NOTE: on Windows use
just -).
-+ or just + Print an extensive usage (help) message, including the explanation of any module-specific
option (but not the GMT common options), then exits.
-? or no arguments Print a complete usage (help) message, including the explanation of options, then
exits.
2.34.6 Examples
To find the likely (hotspot) origins of the seamounts represented by the (x,y,z,r,tc) points in the file
seamounts.d, using the DC85.d Euler poles and the pac_hs.d list of possible hotspots, and report the 2
most likely hotspot candidates for each seamount, run
gmt originator seamounts.d -S2 -EDC85.d -Fpac_hs.d > origins.d
To determine the predicted age of a seamount, distances to the closest hotspot, and echo the observed
age given its location, observed age, and a rotation model, try
echo "1.55 -8.43 52.3" | gmt originator -FONeill_2005_hotspots.txt \
-EOMS2005_APM_fixed.txt -Q1/120 -Lt
where 52.3 Ma is observed age. The output is 70 -95.486 52.3. To repeat the same exercise with a moving
hotspot model, try
echo "1.55 -8.43 52.3" | gmt originator -F+ONeill_2005_hotspots.txt \
-EOMS2005_APM_smooth.txt -Q1/120 -Lt
Now the output is 80 -213.135 52.3. Negative distances means the closest approach was east of the
hotspot.
444
2.34.7 Notes
GMT distributes the EarthByte rotation model Global_EarthByte_230-0Ma_GK07_AREPS.rot. To use
an alternate rotation file, create an environmental parameters named GPLATES_ROTATIONS that
points to an alternate rotation file.
2.34.9 References
Wessel, P., 1999, Hotspotting tools released, EOS Trans. AGU, 80 (29), p. 319.
2.35 rotconverter
rotconverter - Manipulate total reconstruction and stage rotations
2.35.1 Synopsis
rotconverter [ +|- ] rotA [ +|- rotB ] [ +|- rotC ] ... [ -A ] [ -D ] [ -E[fact] ] [ -Fout ] [ -G ] [ -N ] [ -S ] [
-T ] [ -W ] [ -V[level] ] [ -hheaders ]
Note: No space is allowed between the option flag and the associated arguments.
2.35.2 Description
rotconverter reads one or more plate motion models (stage or total reconstruction rotations) stored in
the given files. If more than one plate motion model is given we will add or subtract them in the order
they were listed. The minus sign means we should first transpose the rotation and then add it to the
previous rotation. If a file cannot be opened we will attempt to decode the file name as a single rotation
whose parameters are separated by slashes.
2.35. rotconverter
445
2.35.5 Limitations
Note that only one of -N, -S, and -W can be used at the same time.
2.35.6 Examples
To convert the total reconstruction rotations in the file model_total_reconstruction.APM to stage poles,
run
gmt rotconverter model_total_reconstruction.APM -Fs > model_stages.APM
To obtain Nazca motion relative to Pacific hotspots by adding the motion of Nazca relative to a fixed Pacific to the Pacific-Hotspot reference model DC85_stages.d, and report the result as total reconstruction
reconstruction poles in the northern hemisphere, try
gmt rotconverter DC85_stages.APM + Pac_Naz_stages.RPM -N -Ft > \
Naz_HS_total reconstruction.APM
To add the final rotations ROT(150.1, 70.5, -20.3) and ROT (145.0, 40.0, 11.4), try
gmt rotconverter 150.1/70.5/-20.3 + 145/40/11.4
To compute rotations for India relative to a fixed Africa using the plate circuit India-Central Indian
Basin-Antarctica-Africa, based on the GPlates rotations database, try
gmt rotconverter IND-CIB CIB-ANT ANT-AFR > India_Africa.RPM
2.35.7 Notes
GMT distributes the EarthByte rotation model Global_EarthByte_230-0Ma_GK07_AREPS.rot. To use
an alternate rotation file, create an environmental parameters named GPLATES_ROTATIONS that
points to an alternate rotation file.
2.36 rotsmoother
rotsmoother - Get mean rotations and covariance matrices from set of finite rotation
2.36.1 Synopsis
rotsmoother [ rottable ] [ -A ] [ -C ] [ -N ] [ -S ] [ -Tages ] [ -V[level] ] [ -W ] [ -Z ] [ -bbinary ] [
-dnodata ] [ -hheaders ] [ -iflags ] [ -oflags ] [ -sflags ] [ -:[i|o] ]
Note: No space is allowed between the option flag and the associated arguments.
2.36.2 Description
rotsmoother reads a table of total reconstructions and computes mean rotations (and optionally covariance matrices) for sub-groups of rotations based on rotation age.
447
-N Ensure all poles are in northern hemisphere [Default ensures positive opening angles].
-S Ensure all poles are in southern hemisphere [Default ensures positive opening angles].
-Tages Sets the desired groups of times. For a single time append the desired time. For an equidistant range of reconstruction times give -Tstart/stop/inc or -Tstart/stop/npoints+. For an nonequidistant set of reconstruction times please pass them via the first column in a file, e.g., -Tagefile.
The times indicate read or generated becomes the bin-boundaries and we output the average time
of all rotations inside each bin.
-V[level] (more ...) Select verbosity level [c].
-W Expect weights in last column for a weighted mean rotation [no weights].
-Z Report negative opening angles [positive].
-bi[ncols][t] (more ...) Select native binary input. [Default is 2 input columns].
-bo[ncols][type] (more ...) Select native binary output. [Default is same as input].
-d[i|o]nodata (more ...) Replace input columns that equal nodata with NaN and do the reverse on output.
-h[i|o][n][+c][+d][+rremark][+rtitle] (more ...) Skip or produce header record(s).
-icols[l][sscale][ooffset][,...] (more ...) Select input columns (0 is first column).
-ocols[,...] (more ...) Select output columns (0 is first column).
-s[cols][a|r] (more ...) Set handling of NaN records.
-:[i|o] (more ...) Swap 1st and 2nd column on input and/or output.
-n[b|c|l|n][+a][+bBC][+c][+tthreshold] (more ...) Select interpolation mode for grids.
-^ or just - Print a short message about the syntax of the command, then exits (NOTE: on Windows use
just -).
-+ or just + Print an extensive usage (help) message, including the explanation of any module-specific
option (but not the GMT common options), then exits.
-? or no arguments Print a complete usage (help) message, including the explanation of options, then
exits.
448
coordinates. This default behavior can be bypassed if the ellipsoid setting PROJ_ELLIPSOID is changed
to Sphere.
2.36.7 Examples
To smooth rotation groups in increments of 3 Myr and ensure northern hemisphere poles, try
gmt rotsmoother rotations.txt -N -V > rot_means.txt
2.37 x2sys_binlist
x2sys_binlist - Create bin index listing from track data files
2.37.1 Synopsis
x2sys_binlist track(s) -TTAG [ -D ] [ -E ] [ -V[level] ]
Note: No space is allowed between the option flag and the associated arguments.
2.37.2 Description
x2sys_binlist reads one or more track data files and produces a multisegment ASCII track bin-index file
(tbf) with the track name in the header and one data record per bin crossed; these records contain lon,
lat, index, flags[, dist], where lon, lat are the coordinates of the center of the bin, the index is the 1-D
number of the bin, and flags is a bitflag that describes which data fields were available in this bin. The
optional dist requires -D. The input files can be of any format, which must be described and passed with
the -T option. The bin-index listing is a crude representation of where the track goes and is used by the
data archivist to build an x2sys track data base for miscellaneous track queries, such as when needing to
determine which tracks should be compared in a crossover analysis. You must run x2sys_init to initialize
the tag before you can run the indexing.
2.37. x2sys_binlist
449
2.37.5 Examples
To create a bin index file from the MGD77 file 01030061.mgd77 using the settings associated with the
tag MGD77, do
gmt x2sys_binlist 01030061.mgd77 -TMGD77 > 01030061.tbf
To create a track bin index file of all MGD77+ files residing in the current directory using the settings
associated with the tag MGD77+ and calculate track distances, run
gmt x2sys_binlist *.nc -TMGD77+ -D > all.tbf
2.38 x2sys_cross
x2sys_cross - Calculate crossovers between track data files
2.38.1 Synopsis
x2sys_cross track(s) -TTAG [ -Acombi.lis ] [ -C[runtimes] ] [ -Il|a|c ] [ -Jparameters ] [ -Qe|i ] [ Sl|u|hspeed ] [ -V[level] ] [ -Wsize ] [ -Z ] [ -bobinary ] [ -donodata ]
Note: No space is allowed between the option flag and the associated arguments.
450
2.38.2 Description
x2sys_cross is used to determine all intersections between (external cross-overs) or within (internal cross-overs) tracks (Cartesian or geographic), and report the time, position, distance along track,
heading and speed along each track segment, and the crossover error (COE) and mean values for all
observables. The names of the tracks are passed on the command line. By default, x2sys_cross will look
for both external and internal COEs. As an option, you may choose to project all data using one of the
map-projections prior to calculating the COE.
2.38. x2sys_cross
451
the corresponding region. Alternatively, specify the name of an existing grid file and the -R settings (and grid spacing, if applicable) are copied from the grid. Using -Runit expects projected
(Cartesian) coordinates compatible with chosen -J and we inversely project to determine actual
rectangular geographic region. For perspective view (-p), optionally append /zmin/zmax. In case
of perspective view (-p), a z-range (zmin, zmax) can be appended to indicate the third dimension.
This needs to be done only when using the -Jz option, not when using only the -p option. In the
latter case a perspective view of the plane is plotted, with no third dimension. For Cartesian data
just give xmin/xmax/ymin/ymax. This option limits the COEs to those that fall inside the specified
domain.
-Sl|u|hspeed Defines window of track speeds. If speeds are outside this window we do not calculate a
COE. Specify
-Sl sets lower speed [Default is 0].
-Su sets upper speed [Default is Infinity].
-Sh does not limit the speed but sets a lower speed below which headings will not be computed
(i.e., set to NaN) [Default calculates headings regardless of speed].
-V[level] (more ...) Select verbosity level [c].
-Wsize Give the maximum number of data points on either side of the crossover to use in the spline
interpolation [3].
-Z Report the values of each track at the crossover [Default reports the crossover value and the mean
value].
-bo[ncols][type] (more ...) Select native binary output.
-donodata (more ...) Replace output columns that equal NaN with nodata.
-^ or just - Print a short message about the syntax of the command, then exits (NOTE: on Windows use
just -).
-+ or just + Print an extensive usage (help) message, including the explanation of any module-specific
option (but not the GMT common options), then exits.
-? or no arguments Print a complete usage (help) message, including the explanation of options, then
exits.
2.38.5 Remarks
The COEs found are printed out to standard output in ASCII format (unless -bo is set). When ASCII is
chosen, the output format depends on whether or not old-style XOVER output (-L) has been selected
[See the x_over man page for more details]. If ASCII, then the first record contains the name of the tag
used, the second records specifies the exact command line used for this run, and the third record contains
the names of each column. For each track pair, there will be a segment header record containing the two
file names and their start/stop/dist information (start/stop is absolute time or NaN if unavailable while
dist is the total track length), whereas subsequent records have the data for each COE encountered. The
fields written out are x, y, time along track #1 and #2, distance along track #1 and #2, heading along
track #1 and #2, velocity along track #1 and #2, and then pairs of columns for each selected observable.
These are either pairs of (COE, average value) for each data type (or track-values #1 and #2; see -Z). It
is recommended that the Akima spline is used instead of the natural cubic spline, since it is less sensitive
to outliers that tend to introduce wild oscillations in the interpolation.
452
2.38.8 Examples
To compute all internal crossovers in the gmt-formatted file c2104.gmt, and using the tag GMT, try
gmt x2sys_cross c2104.gmt -TGMT > c2104.d
To find the crossover locations with bathymetry between the two MGD77 files A13232.mgd77 and
A99938.mgd77, using the MGD77 tag, try
gmt x2sys_cross A13232.mgd77 A99938.mgd77 -Qe -TMGD77 > crossovers.d
2.38.9 References
Wessel, P. (2010), Tools for analyzing intersecting tracks: the x2sys package. Computers and Geosciences, 36, 348-354.
Wessel, P. (1989), XOVER: A cross-over error detector for track data, Computers and Geosciences,
15(3), 333-346.
2.39 x2sys_datalist
x2sys_datalist - Extract content of track data files
2.39.1 Synopsis
x2sys_datalist track(s) -TTAG [ -A ] [ -E ] [ -Fname1,name2,...) ] [ -I[list] ] [ -L[corrtable] ] [ -Rregion
] [ -S ] [ [ -V[level] ] [ -bobinary ] [ -donodata ] [ -hheaders ]
Note: No space is allowed between the option flag and the associated arguments.
2.39. x2sys_datalist
453
2.39.2 Description
x2sys_datalist reads one or more files and produces a single ASCII [or binary] table. The files can be
of any format, which must be described and passed with the -T option. You may limit the output to
a geographic region, and insist that the output from several files be separated by a multiple segment
header. Only the named data fields will be output [Default selects all columns].
of perspective view (-p), a z-range (zmin, zmax) can be appended to indicate the third dimension.
This needs to be done only when using the -Jz option, not when using only the -p option. In the
latter case a perspective view of the plane is plotted, with no third dimension. For Cartesian data
just give xmin/xmax/ymin/ymax. This option limits the COEs to those that fall inside the specified
domain.
-S Suppress output records where all the data columns are NaN [Default will output all records].
-V[level] (more ...) Select verbosity level [c].
-bo[ncols][type] (more ...) Select native binary output.
-donodata (more ...) Replace output columns that equal NaN with nodata.
-h[i|o][n][+c][+d][+rremark][+rtitle] (more ...) Skip or produce header record(s).
-^ or just - Print a short message about the syntax of the command, then exits (NOTE: on Windows use
just -).
-+ or just + Print an extensive usage (help) message, including the explanation of any module-specific
option (but not the GMT common options), then exits.
-? or no arguments Print a complete usage (help) message, including the explanation of options, then
exits.
2.39.5 Examples
To extract all data from the old-style MGG supplement file c2104.gmt, recognized by the tag GMT:
gmt x2sys_datalist c2104.gmt -TGMT > myfile
To make lon,lat, and depth input for blockmean and surface using all the files listed in the file tracks.lis
and define by the tag TRK, but only the data that are inside the specified area, and make output binary,
run
gmt x2sys_datalist =tracks.lis -TTRK -Fon,lat,depth -R40/-30/25/35 -bo > alltopo_
bin.xyz
2.39.6 Corrections
The correction table is an ASCII file with coefficients and parameters needed to carry out corrections.
This table is usually produced by x2sys_solve. Comment records beginning with # are allowed. All
correction records are of the form
trackID observation correction
where trackID is the track name, observation is one of the abbreviations for an observed field contained
in files under this TAG, and correction consists of one or more white-space-separated terms that will be
subtracted from the observation before output. Each term must have this exact syntax:
factor[*[function]([scale](abbrev[-origin]))[^power]]
where terms in brackets are optional (the brackets themselves are not used but regular parentheses must
be used exactly as indicated). No spaces are allowed except between terms. The factor is the amplitude
of the basis function, while the optional function can be one of sin, cos, or exp. The optional scale and
origin can be used to translate the argument (before giving it to the optional function). The argument
abbrev is one of the abbreviations for columns known to this TAG. However, it can also be one of the
2.39. x2sys_datalist
455
three auxiliary terms dist (for along-track distances), azim for along-track azimuths, and vel (for alongtrack speed); these are all sensitive to the -C and -N settings used when defining the TAB; furthermore,
vel requires time to be present in the data. If origin is given as T it means that we should replace it with
the value of abbrev for the very first record in the file (this is usually only done for time). If the first data
record entry is NaN we revert origin to zero. Optionally, raise the entire expression to the given power,
before multiplying by factor. The following is an example of fictitious corrections to the track ABC,
implying the z column should have a linear trend removed, the field obs should be corrected by a strange
dependency on latitude, weight needs to have 1 added (hence correction is given as -1), and fuel should
be reduced by a linear distance term:
ABC z 7.1 1e-4*((time-T))
ABC obs 0.5*exp(-1e-3(lat))^1.5
ABC weight -1
ABC fuel 0.02*((dist))
2.40 x2sys_get
x2sys_get - Get track listing from the x2sys track index databases
2.40.1 Synopsis
x2sys_get -TTAG [ -C ] [ -Fflags ] [ -G ] [ -L[+][list] ] [ -Nflags ] [ [ -Rregion ] [ -V[level] ]
Note: No space is allowed between the option flag and the associated arguments.
2.40.2 Description
x2sys_get will return the names of the track data files in the x2sys data base for this TAG that match the
given requirements. You may choose a specific region and optionally ask only for tracks that meet certain
data criteria. Finally, you may select an option to list all possible pairs that might generate crossovers.
456
-Fflags Give a comma-separated list of column names (as described in the definition file) that should be
present. [Default selects all data columns].
-G Report data flags (Y or N) for the entire track rather than just for the portion that is inside the region
set by -R [Default].
-L[+][list] Crossover mode. Return a list of track pairs that should be checked for possible crossovers.
The list is determined from the bin-index data base on the assumption that tracks occupying the
same bin are very likely to intersect. By default we return all possible pairs in the data base.
Append the name of a file with a list of tracks if you want to limit the output to those pairs that
involve at least one of the track names in your list. The output is suitable for the -A option in
x2sys_cross. By default, only external crossover pairs are listed. Use -L+ to include internal pairs
in the list.
-Nflags Give a comma-separated list of column names (as described in the definition file) that must be
absent.
-R[unit]west/east/south/north[/zmin/zmax][r] west, east, south, and north specify the region of interest, 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 w/e/s/n. The two
shorthands -Rg and -Rd stand for global domain (0/360 and -180/+180 in longitude respectively,
with -90/+90 in latitude). Alternatively for grid creation, give Rcodelon/lat/nx/ny, where code is
a 2-character combination of L, C, R (for left, center, or right) and T, M, B for top, middle, or
bottom. e.g., BL for lower left. This indicates which point on a rectangular region the lon/lat coordinate refers to, and the grid dimensions nx and ny with grid spacings via -I is used to create
the corresponding region. Alternatively, specify the name of an existing grid file and the -R settings (and grid spacing, if applicable) are copied from the grid. Using -Runit expects projected
(Cartesian) coordinates compatible with chosen -J and we inversely project to determine actual
rectangular geographic region. For perspective view (-p), optionally append /zmin/zmax. In case
of perspective view (-p), a z-range (zmin, zmax) can be appended to indicate the third dimension.
This needs to be done only when using the -Jz option, not when using only the -p option. In the
latter case a perspective view of the plane is plotted, with no third dimension. For Cartesian data
just give xmin/xmax/ymin/ymax. This option limits the tracks to those that fall at least partly inside
the specified domain.
-V[level] (more ...) Select verbosity level [c].
-^ or just - Print a short message about the syntax of the command, then exits (NOTE: on Windows use
just -).
-+ or just + Print an extensive usage (help) message, including the explanation of any module-specific
option (but not the GMT common options), then exits.
-? or no arguments Print a complete usage (help) message, including the explanation of options, then
exits.
2.40.5 Examples
To find all the tracks associated with the tag MGD77, restricted to occupy a certain region in the south
Pacific, and have at least free air anomalies and bathymetry, try
gmt x2sys_get -V -TMGD77 -R180/240/-60/-30 -Ffaa,depth
To find all the tracks associated with the tag MGD77 that have depth but not twt, try
2.40. x2sys_get
457
To find all the pairs associated with the tag MGD77 that might intersect each other, but only those pairs
which involves tracks in your list new.lis, try
gmt x2sys_get -V -TMGD77 -Lnew.lis > xpairs.lis
2.40.6 Note
The tracks that are returned all have the requested data (-F) within the specified region (-R). Furthermore,
the columns of Y and N for other data types also reflect the content of the track portion within the selected
region, unless -G is set.
2.41 x2sys_init
x2sys_init - Initialize a new x2sys track database
2.41.1 Synopsis
x2sys_init TAG -Ddeffile [ -Cc|f|g|e ] [ -Esuffix ] [ -F ] [ -Gd|g ] [ -Idx[/dy] ] [ -Nd|sunit ] [ -Rregion ] [
-V[level] ] [ -Wt|dgap ]
Note: No space is allowed between the option flag and the associated arguments.
2.41.2 Description
x2sys_init is the starting point for anyone wishing to use x2sys; it initializes a set of data bases that
are particular to one kind of track data. These data, their associated data bases, and key parameters are
given a short-hand notation called an x2sys TAG. The TAG keeps track of settings such as file format,
whether the data are geographic or not, and the binning resolution for track indices. Running x2sys_init
is a prerequisite to running any of the other x2sys programs, such as x2sys_binlist, which will create a
crude representation of where each data track go within the domain and which observations are available;
this information serves as input to x2sys_put which updates the track data base. Then, x2sys_get can be
used to find which tracks and data are available inside a given region. With that list of tracks you can use
x2sys_cross to calculate track crossovers, use x2sys_report to report crossover statistics or x2sys_list to
pull out selected crossover information that x2sys_solve can use to determine track-specific systematic
corrections. These corrections may be used with x2sys_datalist to extract corrected data values for
use in subsequent work. Because you can run x2sys_init you must set the environmental parameter
X2SYS_HOME to a directory where you have write permission, which is where x2sys can keep track
of your settings.
458
459
-Wt|dgap Give t or d and append the corresponding maximum time gap (in user units; this is typically
seconds [Infinity]), or distance (for units, see -N) gap [Infinity]) allowed between the two data
points immediately on either side of a crossover. If these limits are exceeded then a data gap is
assumed and no COE will be determined.
-^ or just - Print a short message about the syntax of the command, then exits (NOTE: on Windows use
just -).
-+ or just + Print an extensive usage (help) message, including the explanation of any module-specific
option (but not the GMT common options), then exits.
-? or no arguments Print a complete usage (help) message, including the explanation of options, then
exits.
If you give - as the oformat then GMTs formatting machinery will be used instead (i.e., FORMAT_FLOAT_OUT, FORMAT_GEO_MAP, FORMAT_DATE_MAP, FORMAT_CLOCK_MAP). Some
file formats already have definition files premade. These include mgd77 (for plain ASCII MGD77 data
files), mgd77+ (for enhanced MGD77+ netCDF files), gmt (for old mgg supplement binary files), xy
(for plain ASCII x, y tables), xyz (same, with one z-column), geo (for plain ASCII longitude, latitude
files), and geoz (same, with one z-column).
2.41.6 Examples
If you have a large set of track data files you can organize them using the x2sys tools. Here we will
outline the steps. Let us assume that your track data file format consist of 2 header records with text
information followed by any number of identically formatted data records with 6 columns (lat, lon,
time, obs1, obs2, obs3) and that files are called *.trk. We will call this the line format. First, we create
the line.def file:
# Define file for the line format
# SKIP 2
# Skip 2 header records
# GEO
# Data are geographic
#name type NaN NaN-proxy scale offset
lat
a
N
0
1
0
lon
a
N
0
1
0
time
a
N
0
1
0
obs1
a
N
0
1
0
obs2
a
N
0
1
0
obs3
a
N
0
1
0
oformat
%9.5f
%10.5f
%7.1f
%7.2f
%7.2f
%7.2f
Next we create the TAG and the TAG directory with the databases for these line track files. Assuming
these contain geographic data and that we want to keep track of the data distribution at a 1 x 1 degree
resolution, with distances in km calculated along geodesics and with speeds given in knots, we may run
gmt x2sys_init LINE -V -G -Dline -Rg -Ce -Ndk -NsN -I1/1 -Etrk
where we have selected LINE to be our x2sys tag. When x2sys tools try to read your line data files
they will first look in the current directory and second look in the file TAG_paths.txt for a list of additional directories to examine. Therefore, create such a file (here LINE_paths.txt) and stick the full
paths to your data directories there. All TAG-related files (definition files, tag files, and track data
bases created) will be expected to be in the directory pointed to by $X2SYS_HOME/TAG (in our case
$X2SYS_HOME/LINE). Note that the argument to -D must contain the full path if the *.def file is not
in the current directory. x2sys_init will copy this file to the $X2SYS_HOME/TAG directory where all
other x2sys tools will expect to find it.
Create tbf file(s): Once the (empty) TAG databases have been initialized we go through a two-step
process to populate them. First we run x2sys_binlist on all our track files to create one (or more)
multisegment track bin-index files (tbf). These contain information on which 1 x 1 degree bins (or
any other blocksize; see -I) each track has visited and which observations (in your case obs1, obs2,
obs3) were actually observed (not all tracks may have all three kinds of observations everywhere).
For instance, if your tracks are listed in the file tracks.lis we may run this command:
gmt x2sys_binlist -V -TLINE :tracks.lis > tracks.tbf
Update index data base: Next, the track bin-index files are fed to x2sys_put which will insert the
information into the TAG databases:
2.41. x2sys_init
461
Search for data: You may now use x2sys_get to find all the tracks within a certain sub-region, and
optionally limit the search to those tracks that have a particular combination of observables. E.g.,
to find all the tracks which has both obs1 and obs3 inside the specified region, run
gmt x2sys_get -V -TLINE -R20/40/-40/-20 -Fobs1,obs3 > tracks.tbf
MGD77[+] or GMT: Definition files already exist for MGD77 files (both standard ASCII and enhanced
netCDF-based MGD77+ files) and the old *.gmt files manipulated by the mgg supplements; for
these data sets the -C and -N will default to great circle distance calculation in km and speed in
m/s. There are also definition files for plain x,y[,z] and lon,lat[,z] tracks. To initiate new track
databases to be used with MGD77 data from NGDC, try
gmt x2sys_init MGD77 -V -Dmgd77 -Emgd77 -Rd -Gd -Nsn -I1/1 -Wt900 -Wd5
where we have chosen a 15 minute (900 sec) or 5 km threshold to indicate a data gap and selected
knots as the speed; the other steps are similar.
Binary files: Let us pretend that your line files actually are binary files with a 128-byte header structure
(to be skipped) followed by the data records and where lon, lat, time are double precision numbers
while the three observations are 2-byte integers which must be multiplied by 0.1. Finally, the first
two observations may be -32768 which means there is no data available. All that is needed is a
different line.def file:
# Define file for the binary line format
# BINARY
# File is now binary
# SKIP 128
# Skip 128 bytes
# GEO
# Data are geographic
#name type NaN NaN-proxy scale offset
lon
d
N
0
1
0
lat
d
N
0
1
0
time
d
N
0
1
0
obs1
h
Y
-32768
0.1
0
obs2
h
Y
-32768
0.1
0
obs3
h
N
0
0.1
0
oformat
%10.5f
%9.5f
%7.1f
%6.1f
%6.1f
%6.1f
oformat
%10.5f
%9.5f
%7.1f
%6.1f
%6.1f
%6.1f
Note we use no scaling or NAN proxies since those issues are usually handled internally in the
462
2.42 x2sys_list
x2sys_list - Extract subset from crossover data base
2.42.1 Synopsis
x2sys_list -Ccolumn -TTAG [ coedbase.txt ] [ -Aasymm_max ] [ -E ] [ -FacdhiInNtTvwxyz ] [ -I[list] ] [
-L[corrtable] ] [ -Nnx_min ] [ -Qe|i ] [ -Rregion ] [ -Strack ] [ -V[level] ] [ -W[list] ] [ -bobinary ]
Note: No space is allowed between the option flag and the associated arguments.
2.42.2 Description
x2sys_list will read the crossover ASCII data base coedbase.txt (or stdin) and extract a subset of the
crossovers based on the other arguments. The output may be ASCII or binary.
463
id numbers of the two tracks, t is time along track in dateTclock format (NaN if not available),
T is elapsed time since start of track along track (NaN if not available), v is speed along track,
w is the composite weight, x is x-coordinate (or longitude), y is y-coordinate (or latitude), and
z is observed value (see -C) along track. If -S is not specified then d,h,n,N,t,T,v results in two
output columns each: first for track one and next for track two (in lexical order of track names);
otherwise, they refer to the specified track only (except for n,N which then refers to the other
track). The sign convention for c,i is track one minus track two (lexically sorted). Time intervals
will be returned according to the TIME_UNIT GMT defaults setting.
-I[list] Name of ASCII file with a list of track names (one per record) that should be excluded from
consideration [Default includes all tracks].
-L[corrtable] Apply optimal corrections to the chosen observable. Append the correction table to
use [Default uses the correction table TAG_corrections.txt which is expected to reside in the
$X2SYS_HOME/TAG directory]. For the format of this file, see x2sys_solve.
-Nnx_min Only report data from pairs that generated at least nx_min crossovers between them [use all
pairs].
-Qe|i Append e for external crossovers or i for internal crossovers only [Default is all crossovers].
-R[unit]west/east/south/north[/zmin/zmax][r] west, east, south, and north specify the region of interest, 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 w/e/s/n. The two
shorthands -Rg and -Rd stand for global domain (0/360 and -180/+180 in longitude respectively,
with -90/+90 in latitude). Alternatively for grid creation, give Rcodelon/lat/nx/ny, where code is
a 2-character combination of L, C, R (for left, center, or right) and T, M, B for top, middle, or
bottom. e.g., BL for lower left. This indicates which point on a rectangular region the lon/lat coordinate refers to, and the grid dimensions nx and ny with grid spacings via -I is used to create
the corresponding region. Alternatively, specify the name of an existing grid file and the -R settings (and grid spacing, if applicable) are copied from the grid. Using -Runit expects projected
(Cartesian) coordinates compatible with chosen -J and we inversely project to determine actual
rectangular geographic region. For perspective view (-p), optionally append /zmin/zmax. In case
of perspective view (-p), a z-range (zmin, zmax) can be appended to indicate the third dimension.
This needs to be done only when using the -Jz option, not when using only the -p option. In the
latter case a perspective view of the plane is plotted, with no third dimension. For Cartesian data
just give xmin/xmax/ymin/ymax. This option bases the statistics on those COE that fall inside the
specified domain.
-Strack Name of a single track. If given we restrict output to those crossovers involving this track
[Default output is crossovers involving any track pair].
-V[level] (more ...) Select verbosity level [c].
-W[list] Name of ASCII file with a list of track names and their relative weights (one track per record)
that should be used to calculate the composite crossover weight (output code w above). [Default
sets weights to 1].
-bo[ncols][type] (more ...) Select native binary output.
-^ or just - Print a short message about the syntax of the command, then exits (NOTE: on Windows use
just -).
-+ or just + Print an extensive usage (help) message, including the explanation of any module-specific
option (but not the GMT common options), then exits.
464
-? or no arguments Print a complete usage (help) message, including the explanation of options, then
exits.
2.42.5 Examples
To find all the magnetic crossovers associated with the tag MGD77 from the file COE_data.txt, restricted
to occupy a certain region in the south Pacific, and return location, time, and crossover value, try
gmt x2sys_list COE_data.txt -V -TMGD77 -R180/240/-60/-30 -Cmag -Fxytz > mag_coe.
txt
To find all the faa crossovers globally that involves track 12345678 and output time since start of the
year, using a binary double precision format, try
gmt x2sys_list COE_data.txt -V -TMGD77 -Cfaa -S12345678 -FTz -bod > faa_coe.b
2.43 x2sys_merge
x2sys_merge - Merge an updated COEs table (smaller) into the main table (bigger)
2.43.1 Synopsis
x2sys_merge -Amain_COElist.d -Mnew_COElist.d
Note: No space is allowed between the option flag and the associated arguments.
2.43.2 Description
x2sys_merge will read two crossovers data base and output the contents of the main one updated with
the COEs in the second one. The second file should only contain updated COEs relatively to the first
one. That is, it MUST NOT contain any new two tracks intersections (This point is NOT checked in the
code). This program is useful when, for any good reason like file editing NAV correction or whatever,
one had to recompute only the COEs between the edited files and the rest of the database.
2.43. x2sys_merge
465
2.44 x2sys_put
x2sys_put - Update track index database from track bin file
2.44.1 Synopsis
x2sys_put [ info.tbf ] -TTAG [ -D ] [ -F ] [ -V[level] ]
Note: No space is allowed between the option flag and the associated arguments.
2.44.2 Description
x2sys_put accepts a track bin-index file created by x2sys_binlist and adds this information about the
data tracks to the relevant data base. You may chose to overwrite existing data with new information for
older tracks (-F) and even completely remove information for certain tracks (-D). The x2sys TAG must
match the tag encoded in the info.tbf file. To inquire about tracks in the data base, use x2sys_get.
-? or no arguments Print a complete usage (help) message, including the explanation of options, then
exits.
2.44.5 Examples
To add the information stored in the track bin-index file latest.tbf to the track data bases associated with
the tag MGD77, and replace any exiting information for these tracks, try
gmt x2sys_put latest.tbf -F -V -TMGD77
2.45 x2sys_report
x2sys_report - Report statistics from crossover data base
2.45.1 Synopsis
x2sys_report -Ccolumn -TTAG [ coedbase.txt ] [ -A ] [ -I[list] ] [ -L[corrtable] ] [ -Nnx_min ] [ -Qe|i ]
[ [ -Rregion ] [ -Strack ] [ -V[level] ]
Note: No space is allowed between the option flag and the associated arguments.
2.45.2 Description
x2sys_report will read the input crossover ASCII data base coedbase.txt (or stdin) and report on the
statistics of crossovers (n, mean, stdev, rms, weight) for each track. Options are available to let you
exclude tracks and limit the output.
2.45. x2sys_report
467
-Ccolumn Specify which data column you want to process. Crossovers related to this column name
must be present in the crossover data base.
-TTAG Specify the x2sys TAG which tracks the attributes of this data type.
468
2.45.5 Examples
To report statistics of all the external magnetic crossovers associated with the tag MGD77 from the file
COE_data.txt, restricted to occupy a certain region in the south Pacific, try
gmt x2sys_report COE_data.txt -V -TMGD77 -R180/240/-60/-30 -Cmag >
mag_report.txt
To report on the faa crossovers globally that involves track 12345678, try
gmt x2sys_report COE_data.txt -V -TMGD77 -Cfaa -S2345678 > faa_report.txt
2.45.6 References
Mittal, P. K. (1984), Algorithm for error adjustment of potential field data along a survey network,
Geophysics, 49(4), 467-469.
2.46 x2sys_solve
x2sys_solve - Determine least-squares systematic correction from crossovers
2.46.1 Synopsis
x2sys_solve -Ccolumn -TTAG -Emode [ COE_list.d ] [ -V[level] ] [ -W[u] ] [ -bibinary ] [ -dinodata ]
[ -x[[-]n] ]
Note: No space is allowed between the option flag and the associated arguments.
2.46.2 Description
x2sys_solve will use the supplied crossover information to solve for systematic corrections that can then
be applied per track to improve data quality. Several systematic corrections can be solved for using a
least-squares approach. Note: Only one data column can be processed at the time.
469
-Emode The correction type you wish to model. Choose among the following functions f(p) , where p
are the m parameters per track that we will fit simultaneously using a least squares approach:
c will fit f(p) = a (a constant offset); records must contain track ID1, ID2, COE.
d will fit f(p) = a + b * d (linear drift; d is distance; records must contain track ID1, ID2, d1, d2,
COE.
g will fit f(p) = a + b sin(y)^2 (1980-1930 gravity correction); records must contain track ID1,
ID2, latitude y, COE.
h will fit f(p) = a + b cos(H) + c cos(2H) + d sin(H) + e sin(2H) (magnetic heading correction);
records must contain track ID1, ID2, heading H, COE.
s will fit f(p) = a * z (a unit scale correction); records must contain track ID1, ID2, z1, z2.
t will fit f(p) = a + b * (t - t0) (linear drift; t0 is the start time of the track); records must contain
track ID1, ID2, t1-t0, t2-t0, COE.
2.46.5 Notes
Most of the model corrections in -E involve a constant offset. Because crossovers are differences between values, any absolute level will cancel out and hence the constant offsets we obtain are relative
to an undetermined absolute level. To obtain a solvable solution we add the constraint that the sum of
all constant offsets equal zero. If the tracks form clusters in which no tracks from one cluster cross
any track from another cluster then these are two independent data sets and require they own constraint
equation for their offsets. We determine the number of clusters and automatically add the required constraint equations. If you need a particular reference track to have a particular offset (e.g., 0) then you can
subtract the offset you found from every track correction and add in the desired offset.
2.46.6 Examples
To fit a simple bias offset to faa for all tracks under the MGD77 tag, try
470
To estimate heading corrections based on magnetic crossovers associated with the tag MGD77 from the
file COE_data.txt, try
gmt x2sys_list COE_data.txt -V -TMGD77 -Cmag -Fnhc > mag_coe.txt
gmt x2sys_solve mag_coe.txt -V -TMGD77 -Cmag -Eh > coe_table.txt
2.46. x2sys_solve
471
472
Index
B
backtracker, 428
blockmean, 1
blockmedian, 3
blockmode, 5
D
dimfilter, 393
F
filter1d, 8
fitcircle, 10
G
gmt, 29
gmt.conf, 14
gmt2kml, 45
gmt5syntax, 50
gmt_shell_functions.sh, 13
gmtcolors, 51
gmtconnect, 62
gmtconvert, 65
gmtdefaults, 69
gmtflexure, 396
gmtget, 70
gmtgravmag3d, 398
gmtinfo, 71
gmtlogo, 73
gmtmath, 75
gmtregress, 84
gmtselect, 87
gmtset, 92
gmtsimplify, 93
gmtspatial, 95
gmtswitch, 99
gmtvector, 102
gmtwhich, 104
gravfft, 400
grd2cpt, 105
grd2rgb, 108
grd2xyz, 110
grdblend, 112
grdclip, 115
grdcontour, 117
grdconvert, 122
grdcut, 126
grdedit, 128
grdfft, 130
grdfilter, 134
grdflexure, 405
grdgradient, 137
grdgravmag3d, 409
grdhisteq, 140
grdimage, 142
grdinfo, 145
grdlandmask, 147
grdmask, 150
grdmath, 153
grdpaste, 163
grdpmodeler, 430
grdproject, 165
grdraster, 167
grdredpol, 411
grdrotater, 433
grdsample, 169
grdseamount, 413
grdspotter, 436
grdtrack, 171
grdtrend, 176
grdvector, 177
grdview, 181
grdvolume, 184
greenspline, 186
gshhg, 331
H
hotspotter, 439
473
img2grd, 333
isogmt, 192
rotconverter, 445
rotsmoother, 447
kml2gmt, 192
sample1d, 294
segy2grd, 425
spectrum1d, 297
sph2grd, 301
sphdistance, 303
sphinterpolate, 306
sphtriangulate, 308
splitxyz, 310
surface, 313
M
makecpt, 194
mapproject, 197
mgd77convert, 359
mgd77info, 362
mgd77list, 364
mgd77magref, 372
mgd77manage, 375
mgd77path, 381
mgd77sniffer, 383
mgd77track, 390
nearneighbor, 201
talwani2d, 416
talwani3d, 418
trend1d, 316
trend2d, 319
triangulate, 322
originator, 442
x2sys_binlist, 449
x2sys_cross, 450
x2sys_datalist, 453
x2sys_get, 456
x2sys_init, 458
x2sys_list, 463
x2sys_merge, 465
x2sys_put, 466
x2sys_report, 467
x2sys_solve, 469
xyz2grd, 325
P
postscriptlight, 244
project, 204
psbasemap, 207
psclip, 216
pscoast, 218
pscontour, 224
psconvert, 229
pscoupe, 337
pshistogram, 234
psimage, 237
pslegend, 240
psmask, 256
psmeca, 342
pspolar, 347
psrose, 259
pssac, 356
psscale, 263
pssegy, 420
pssegyz, 423
pstext, 267
psvelo, 351
pswiggle, 270
psxy, 272
psxyz, 284
474
Index