grdcontour - Make contour map using a grid


grdcontour grid -C[+]cont_int|cpt -Jparameters [ -A[-|[+]annot_int][labelinfo] ] [ -B[p|s]parameters ] [ -Dtemplate ] [ -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[+sfactor][+oshift][+p] ] [ -bobinary ] [ -donodata ] [ -eregexp ] [ -fflags ] [ -ho[n] ] [ -pflags ] [ -ttransp ]



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.

Required Arguments

2-D gridded data set to be contoured. (See GRID FILE FORMATS below).


  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.


-Jparameters (more …)
Select map projection.

Optional Arguments

annot_int is annotation interval in data units; it is ignored if contour levels are given in a file. [Default is no annotations]. Append - to disable all annotations implied by -C. Alternatively prepend + to the annotation interval to plot that as a single contour. 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:
For annotations at a fixed angle, +an for contour-normal, or +ap for contour-parallel [Default]. For +ap, you may optionally append u for up-hill and d for down-hill cartographic annotations.
Turns on debug which will draw helper points and lines to illustrate the workings of the contour line setup.
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.
Sets label justification [Default is MC].
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 contour; use +N to force increments in the plot x/y coordinates system [no nudging]. Not allowed with +v.
Draws the outline of text boxes [Default is no outline]; optionally specify pen for outline [Default is width = 0.25p, color = black, style = solid].
-B[p|s]parameters (more …)
Set map boundary frame and axes attributes.





-Jz|Zparameters (more …)
Set z-axis scaling; same syntax as -Jx.
-K (more …)
Do not finalize the PostScript plot.
-O (more …)
Append to existing PostScript plot.
-P (more …)
Select “Portrait” plot orientation.
Specify the region of interest.


Draw GMT time stamp logo on plot.
-V[level] (more …)
Select verbosity level [c].
type, if present, can be a for annotated contours or c for regular contours [Default]. The pen sets the attributes for the particular line. Default pen for annotated contours: 0.75p,black. Regular contours use pen 0.25p,black. If the modifier +cl is appended then the color of the contour lines are taken from the CPT (see -C). If instead modifier +cf is appended then the color from the cpt file is applied to the contour annotations. Use just +c for both effects.


Shift plot origin.
-bo[ncols][type] (more …)
Select native binary output.
-donodata (more …)
Replace output columns that equal NaN with nodata.
-f[i|o]colinfo (more …)
Specify data types of input and/or output columns.
Skip or produce header record(s).
Select perspective view.
-t[transp] (more …)
Set PDF transparency level in percent.
-^ or just -
-+ or just +
-? or no arguments

ASCII Format Precision


Grid File Formats





To contour the file 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 -Jm0.5i -C25 -A50+f10p -B1g30m >

To contour the file 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 -Jx0.1c/50.0c -Ccont.d -S4 -Bx20 -By0.1 \
           -B+t"RMS Misfit" -Wathick,red -Wcthinnest,blue,- | lp


To save the smoothed 100-m contour lines in and separate them into two multisegment files: contours_C.txt for closed and contours_O.txt for open contours, try

gmt grdcontour -C100 -S4 -Dcontours_%c.txt