gmt¶
gmt - The Generic Mapping Tools data processing and display software package
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.
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. A few special modules are also available:
gmt clear items
while delete the user’s history. Choose between history (deletes the gmt.history file in the current directory), conf (deletes the gmt.conf file in the current directory), cache (deletes the user’s cache directory and all of its content), or all (does all of the above).
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.
Command-line completion¶
GMT provides basic command-line completion (tab completion) for bash.
The completion rules are either installed in /etc/bash_completion.d/gmt
or <prefix>/share/tools/gmt_completion.bash
. Depending on the
distribution, you may still need to source the gmt completion file from
~/.bash_completion
or ~/.bashrc
. For more information see Section
Command-line completion in the CookBook.
GMT Overview¶
The following is a summary of all the programs supplied with GMT and a very short description of their purpose. Detailed information about each program can be found in the separate manual pages.
blockmean | |
blockmedian | |
blockmode | |
filter1d | |
fitcircle | |
gmt2kml | |
gmtconnect | |
gmtconvert | |
gmtdefaults | |
gmtget | |
gmtinfo | |
gmtmath | |
gmtselect | |
gmtset | |
gmtspatial | |
gmtsimplify | |
gmtvector | |
gmtwhich | |
grd2cpt | |
grd2rgb | |
grd2xyz | |
grdblend | |
grdclip | |
grdcontour | |
grdconvert | |
grdcut | |
grdedit | |
grdfft | |
grdfilter | |
grdgradient | |
grdhisteq | |
grdimage | |
grdinfo | |
grdlandmask | |
grdmask | |
grdmath | |
grdpaste | |
grdproject | |
grdraster | |
grdsample | |
grdtrack | |
grdtrend | |
grdvector | |
grdview | |
grdvolume | |
greenspline | |
kml2gmt | |
makecpt | |
mapproject | |
nearneighbor | |
project | |
psbasemap | |
psclip | |
pscoast | |
pscontour | |
psconvert | |
pshistogram | |
psimage | |
pslegend | |
psmask | |
psrose | |
psscale | |
pstext | |
pswiggle | |
psxy | |
psxyz | |
sample1d | |
spectrum1d | |
splitxyz | |
surface | |
trend1d | |
trend2d | |
triangulate | |
xyz2grd | |
Supplement gshhg: | |
gshhg | |
Supplement img: | |
img2grd | |
Supplement meca: | |
pscoupe | |
psmeca | |
pspolar | |
psvelo | |
pssac | |
Supplement mgd77: | |
mgd77convert | |
mgd77header | |
mgd77info | |
mgd77list | |
mgd77magref | |
mgd77manage | |
mgd77path | |
mgd77sniffer | |
mgd77track | |
Supplement potential: | |
gmtgravmag3d | |
gmtflexure | |
gpsgridder | |
gravfft | |
grdflexure | |
grdgravmag3d | |
grdredpol | |
grdseamount | |
talwani2d | |
talwani3d | |
Supplement segy: | |
pssegy | |
pssegyz | |
segy2grd | |
Supplement sph: | |
sphdistance | |
sphinterpolate | |
sphtriangulate | |
Supplement spotter: | |
backtracker | |
gmtpmodeler | |
grdpmodeler | |
grdrotater | |
grdspotter | |
hotspotter | |
originator | |
rotconverter | |
rotsmoother | |
Supplement x2sys: | |
x2sys_binlist | |
x2sys_cross | |
x2sys_datalist | |
x2sys_get | |
x2sys_init | |
x2sys_list | |
x2sys_merge | |
x2sys_put | |
x2sys_report | |
x2sys_solve |
Custom Modules¶
The gmt program can also load custom modules from shared libraries built as specified in the GMT API documentation. This way your modules can benefit form the GMT infrastructure and extend GMT in specific ways.
The Common GMT Options¶
-B[p|s]parameters -Jparameters -Jz|Zparameters -K -O -P -Rwest/east/south/north[/zmin/zmax][+r] -U[stamp] -V[level] -Xx_offset -Yy_offset -aflags -bbinary -dnodata -fflags -ggaps -hheaders -iflags -nflags -oflags -pflags -r -sflags -ttransp -x[[-]n] -:[i|o]
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][+l|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 3-D basemap is selected with -p and -Jz, use -Bz to give settings for the vertical axis.). To add a 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 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 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:- 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 n’t magnitude. This option can also be used for the frame and grid intervals.
- An l is appended to the tickinfo string. Then, log10 of the tick value is plotted at every integer log10 value.
- 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:
- stride sets the regular annotation interval.
- 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).
Give projection center lon0/lat0 and scale (1:xxxx or UNIT/degree).
-Jcyl_stere/[lon0/[lat0/]]scale or -JCyl_stere/[lon0/[lat0/]]width (Cylindrical Stereographic).
Give central meridian lon0 (optional), standard parallel lat0 (optional), and scale along parallel (1:xxxx or UNIT/degree). The standard parallel is typically one of these (but can be any value):
- 66.159467 - Miller’s modified Gall
- 55 - Kamenetskiy’s First
- 45 - Gall’s Stereographic
- 30 - Bolshoi Sovietskii Atlas Mira or Kamenetskiy’s Second
- 0 - Braun’s Cylindrical
-Jj[lon0/]scale or -JJ[lon0/]width (Miller Cylindrical Projection).
Give the central meridian lon0 (optional) and scale (1:xxxx or UNIT/degree).
-Jm[lon0/[lat0/]]scale or -JM[lon0/[lat0/]]width (Mercator [C])
Give central meridian lon0 (optional), standard parallel lat0 (optional), and scale along parallel (1:xxxx or UNIT/degree).
-Joparameters (Oblique Mercator [C]).
Typically used with -RLLx/LLy/URx/URyr or with projected coordinates. Specify one of:
- -Jo[a|A]lon0/lat0/azimuth/scale or -JO[a|A]lon0/lat0/azimuth/width
- Set projection center lon0/lat0, azimuth of oblique equator, and scale.
- -Jo[b|B]lon0/lat0/lon1/lat1/scale or -JO[b|B]lon0/lat0/lon1/lat1/scale
- Set projection center lon0/lat0, another point on the oblique equator lon1/lat1, and scale.
- -Joc|Clon0/lat0/lonp/latp/scale or -JOc|Clon0/lat0/lonp/latp/scale
- Set projection center lon0/lat0, pole of oblique projection lonp/latp, and scale. Give scale along oblique equator (1:xxxx or UNIT/degree). The upper-case A|B|C to removes enforcement of a northern hemisphere pole.
-Jq[lon0/[lat0/]]scale or -JQ[lon0/[lat0/]]width (Cylindrical Equidistant).
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):
- 61.7 - Grafarend and Niermann, minimum linear distortion
- 50.5 - Ronald Miller Equirectangular
- 43.5 - Ronald Miller, minimum continental distortion
- 42 - Grafarend and Niermann
- 37.5 - Ronald Miller, minimum overall distortion
- 0 - Plate Carree, Simple Cylindrical, Plain/Plane Chart
-Jtlon0/[lat0/]scale or -JTlon0/[lat0/]width (Transverse Mercator [C])
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
- 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 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/Height/width (General Perspective).
- 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.
-Jxx-scale[/y-scale] or -JXwidth[/height] (Linear, log, and power scaling)
Give x-scale (1:xxxx or UNIT/x-unit) and/or y-scale (1:xxxx or UNIT/y-unit); or specify width and/or height in UNIT. y-scale=x-scale if not specified separately and using 1:xxxx implies that x-unit and y-unit are in meters. Use negative scale(s) to reverse the direction of an axis (e.g., to have y be positive down). Set height or width to 0 to have it recomputed based on the implied scale of the other axis. Optionally, append to x-scale, y-scale, width or height one of the following:
- d
- Data are geographical coordinates (in degrees).
- l
- Take log10 of values before scaling.
- ppower
- Raise values to power before scaling.
- t
- Input coordinates are time relative to TIME_EPOCH.
- T
- Input coordinates are absolute time.
For mixed axes with only one geographic axis you may need to set -f as well. Default axis lengths (see gmt.conf) can be invoked using -JXh (for landscape); -JXv (for portrait) will swap the x- and y-axis lengths. The default unit for this installation is either cm or inch, as defined in the file share/gmt.conf. However, you may change this by editing your gmt.conf file(s).
When -J is used without any further arguments, or just with the projection type, the arguments of the last used -J, or the last used -J with that projection type, will be used.
- -Jz|Zparameters
- Set z-axis scaling; same syntax as -Jx.
- -K
- More PostScript code will be appended later [Default terminates the plot system]. Required for all but the last plot command when building multi-layer plots.
- -O
- Selects Overlay plot mode [Default initializes a new plot system]. Required for all but the first plot command when building multi-layer plots.
- -P
- Select “Portrait” plot orientation [Default is “Landscape”; see gmt.conf or gmtset to change the PS_PAGE_ORIENTATION parameter, or supply --PS_PAGE_ORIENTATION=orientation on the command line].
- -Rxmin/xmax/ymin/ymax[+r][+uunit]
- xmin, xmax, ymin, and ymax specify the region of interest. For geographic regions, these limits correspond to west, east, south, and north and you may specify them in decimal degrees or in [+|-]dd:mm[:ss.xxx][W|E|S|N] format. Append +r if lower left and upper right map coordinates are given instead of west/east/south/north. 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 -Rcodex0/y0/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 x0/y0 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. When -R is used without any further arguments, the values from the last use of -R in a previous GMT command will be used. For calendar time coordinates you may either give (a) relative time (relative to the selected TIME_EPOCH and in the selected TIME_UNIT; append t to -JX|x), or (b) absolute time of the form [date]T[clock] (append T to -JX|x). At least one of date and clock must be present; the T is always required. The date string must be of the form [-]yyyy[-mm[-dd]] (Gregorian calendar) or yyyy[-Www[-d]] (ISO week calendar), while the clock string must be of the form hh:mm:ss[.xxx]. The use of delimiters and their type and positions must be 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. Append the length unit via the +u modifier, (e.g., -R-200/200/-300/300+uk 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 [LL]. 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 more 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 (x-shift,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 use 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: 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
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 big-endian,
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. (Example)
X
-bio example
# Write a binary file, and read it back, with 3 columns in which the first # is a 4 bytes float, second a 8 bytes long int and third a 8 bytes double. echo 1.5 2 2.5 | gmt gmtconvert -bo1f,1l,1d > lixo.bin gmt gmtconvert lixo.bin -bi1f,1l,1d
- -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.
- -d[i|o]nodata
- Control how user-coded missing 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.
- -e[~]”pattern” | -e[~]/regexp/[i]
- Only accept ASCII data records that contains the specified pattern. To reverse the search, i.e., to only accept data record that do not contain the specified pattern, use -e~. Should your pattern happen to start with ~ you need to escape this character with a backslash [Default accepts all data records]. For matching data records 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.
- -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. Shorthands -f[i|o]g means -f[i|o]0x,1y (geographic coordinates) and -f[i|o]c means -f[i|o]0-1f (Cartesian 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]
- Primary input file(s) has header record(s). If used, the default number of header records is IO_N_HEADER_RECS [1]. Use -hi if only the primary 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 primary 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 be repeated. To each column, optionally add any of the following: +l takes log10 of the input values first; +sscale, subsequently multiplies by a given scale factor [1]; +ooffset, finally adds a given offset [0].
- -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 primary 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. Alternatively, you can perform a simple rotation about the z-axis by just giving the rotation angle. Optionally, use +v or +w to select another axis location than the plot origin.
- -r
- Force pixel node registration [Default is gridline registration]. (Node registrations are defined in Section Grid registration: The -r option 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 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 just use -).
- -+ 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 all 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 gmtcolors for more information and a full list of color names.
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 ppattern, where pattern set the number of the built-in pattern (1-90) or the name of a raster image file. The optional +rdpi sets the resolution of the image [1200]. For 1-bit rasters: use upper case P for inverse video, or append +fcolor and/or +bcolor to specify fore- and background colors (use color = - for transparency). See GMT Cookbook & Technical Reference Appendix E for information on individual built-in 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:
- Helvetica
- Helvetica-Bold
- Helvetica-Oblique
- Helvetica-BoldOblique
- Times-Roman
- Times-Bold
- Times-Italic
- Times-BoldItalic
- Courier
- Courier-Bold
- Courier-Oblique
- Courier-BoldOblique
- Symbol
- AvantGarde-Book
- AvantGarde-BookOblique
- AvantGarde-Demi
- AvantGarde-DemiOblique
- Bookman-Demi
- Bookman-DemiItalic
- Bookman-Light
- Bookman-LightItalic
- Helvetica-Narrow
- Helvetica-Narrow-Bold
- Helvetica-Narrow-Oblique
- Helvetica-Narrow-BoldOblique
- NewCenturySchlbk-Roman
- NewCenturySchlbk-Italic
- NewCenturySchlbk-Bold
- NewCenturySchlbk-BoldItalic
- Palatino-Roman
- Palatino-Italic
- Palatino-Bold
- Palatino-BoldItalic
- ZapfChancery-MediumItalic
- ZapfDingbats
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 can be any of ‘solid’, ‘dashed’ or ‘dotted’, or a custom 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 Specifying pen attributes for more information.
ASCII Format Precision¶
The ASCII output formats of numerical data are controlled by parameters in your gmt.conf file. Longitude and latitude are formatted according to FORMAT_GEO_OUT, absolute time is under the control of FORMAT_DATE_OUT and FORMAT_CLOCK_OUT, whereas general floating point values are formatted according to FORMAT_FLOAT_OUT. Be aware that the format in effect can lead to loss of precision in ASCII 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.
Grid File Formats¶
By default GMT writes out grid as single precision floats in a COARDS-complaint netCDF file format. However, GMT is able to produce and read grid files in many other commonly used grid file formats and also facilitates so called “packing” of grids, writing out floating point data as 1- or 2-byte integers. To specify the precision, scale and offset, the user should add the suffix =id[/scale/offset[/nan]], where id is a two-letter identifier of the grid type and precision, and scale and offset are optional scale factor and offset to be applied to all grid values, and nan is the value used to indicate missing data. In case the two characters id is not provided, as in =/scale than a id=nf is assumed. When reading grids, the format is generally automatically recognized from almost all of those formats that GMT and GDAL combined offer. If not, the same suffix can be added to input grid file names. See grdconvert and Section Grid file format specifications of the GMT Technical Reference and Cookbook for more information.
When reading a netCDF file that contains multiple grids, GMT will read, by default, the first 2-dimensional grid that can find in that file. To coax GMT into reading another multi-dimensional variable in the grid file, append ?varname to the file name, where varname is the name of the variable. Note that you may need to escape the special 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. The ?varname suffix can also be used for output grids to specify a variable name different from the default: “z”. See grdconvert and Sections Modifiers for COARDS-compliant netCDF files and Grid file format specifications of the GMT Technical Reference and Cookbook for more information, particularly on how to read splices of 3-, 4-, or 5-dimensional grids.
See Also¶
Look up the individual man pages for more details and full syntax. Run
gmt --help
to list all GMT programs and to show all installation
directories. For an explanation of the various GMT settings in this
man page (like FORMAT_FLOAT_OUT), see the man page of the GMT
configuration file gmt.conf. Information is also available on the
GMT home page http://gmt.soest.hawaii.edu/