# TRIANGULATE

NAME
SYNOPSIS
DESCRIPTION
OPTIONS
ASCII FORMAT PRECISION
GRID VALUES PRECISION
EXAMPLES
SEE ALSO
REFERENCES

## NAME

triangulate − Perform optimal Delauney triangulation and gridding of Cartesian data [method]

## SYNOPSIS

triangulate infiles [ −Dx|y ] [ −E empty ] [ −F ] [ −G grdfile ] [ −H[i][nrec] ] [ −I xinc[unit][=|+][/yinc[unit][=|+]] ] [ −J parameters ] [ −M[i|o][flag] ] [ −R west/east/south/north[r] ] [ −V ] [ −Z ] [ −:[i|o] ] [ −b[i|o][s|S|d|D[ncol]|c[var1/...]] ] [ −f[i|o]colinfo ]

## DESCRIPTION

triangulate reads one or more ASCII [or binary] files (or standard input) containing x,y[,z] and performs Delauney 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.
infiles

Data files with the point coordinates in ASCII (or binary; see −b). If no files are given the standard input is read.

## OPTIONS

| −D |  | Take either the x- or y-derivatives of surface represented by the planar facets (only used when −G is set).
| −E |  | Set the value assigned to empty nodes when −G is set [NaN].
| −F |  | Force pixel node registration [Default is gridline registration]. (Node registrations are defined in GMT Cookbook Appendix B on grid file formats.) Only valid with −G).
| −G |  | Use triangulation to grid the data onto an even grid (specified with −I, −R). Append the name of the output grid file. The interpolation is performed in the original coordinates, so if your triangles are close to the poles you are better off projecting all data to a local coordinate system before using triangulate (this is true of all gridding routines).
| −H |  | Input file(s) has Header record(s). Number of header records can be changed by editing your .gmtdefaults4 file. If used, GMT default is 1 header record. 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.
| −I |  | x_inc [and optionally y_inc] sets the grid size for optional grid output (see −G). Append m to indicate minutes or c to indicate seconds.

−J

Selects the map projection. Scale is UNIT/degree, 1:xxxxx, or width in UNIT (upper case modifier). UNIT is cm, inch, or m, depending on the MEASURE_UNIT setting in .gmtdefaults4, but this can be overridden on the command line by appending c, i, or m to the scale/width value. When central meridian is optional, default is center of longitude range on −R option. Default standard parallel is the equator. For map height, max dimension, or min dimension, append h, +, or - to the width, respectively.

More details can be found in the psbasemap man pages.

CYLINDRICAL PROJECTIONS:

−Jc lon0/lat0/scale (Cassini)
−Jcyl_stere/[lon0/[lat0/]]scale (Cylindrical Stereographic)
−Jj[lon0/]scale (Miller)
−Jm[lon0/[lat0/]]scale (Mercator)
−Jm lon0/lat0/scale (Mercator - Give meridian and standard parallel)
−Jo[a]lon0/lat0/azimuth/scale (Oblique Mercator - point and azimuth)
−Jo[b]lon0/lat0/lon1/lat1/scale (Oblique Mercator - two points)
−Joc lon0/lat0/lonp/latp/scale (Oblique Mercator - point and pole)
−Jq[lon0/[lat0/]]scale (Cylindrical Equidistant)
−Jt lon0/[lat0/]scale (TM - Transverse Mercator)
−Ju zone/scale (UTM - Universal Transverse Mercator)
−Jy[lon0/[lat0/]]scale (Cylindrical Equal-Area)

CONIC PROJECTIONS:

−Jb lon0/lat0/lat1/lat2/scale (Albers)
−Jd lon0/lat0/lat1/lat2/scale (Conic Equidistant)
−Jl lon0/lat0/lat1/lat2/scale (Lambert Conic Conformal)

AZIMUTHAL PROJECTIONS:

−Ja lon0/lat0[/horizon]/scale (Lambert Azimuthal Equal-Area)
−Je lon0/lat0[/horizon]/scale (Azimuthal Equidistant)
−Jf lon0/lat0[/horizon]/scale (Gnomonic)
−Jg lon0/lat0[/horizon]/scale (Orthographic)
−Jg lon0/lat0/altitude/azimuth/tilt/twist/Width/Height/scale (General Perspective).
−Js lon0/lat0[/horizon][/slat]/scale (General Stereographic)

MISCELLANEOUS PROJECTIONS:

−Jh[lon0/]scale (Hammer)
−Ji[lon0/]scale (Sinusoidal)
−Jkf[lon0/]scale (Eckert IV)
−Jk[s][lon0/]scale (Eckert IV)
−Jn[lon0/]scale (Robinson)
−Jr[lon0/]scale (Winkel Tripel)
−Jv[lon0/]scale (Van der Grinten)
−Jw[lon0/]scale (Mollweide)

NON-GEOGRAPHICAL PROJECTIONS:

−Jp[a]scale[/origin][r|z] (Polar coordinates (theta,r))
−Jx x-scale[d|l|p pow|t|T][/y-scale[d|l|p pow|t|T]] (Linear, log, and power scaling)

| −M |  | Output triangulation network as multiple line segments separated by a record whose first character is flag [>]. To plot, use psxy with the −M option (see Examples).

−R

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 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). 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 gmtdefaults).

| −V |  | Selects verbose mode, which will send progress reports to stderr [Default runs "silently"].
| −Z |  | Controls whether binary data file has two or three columns [2]. Ignored if −b is not set.
| −: |  | Toggles between (longitude,latitude) and (latitude,longitude) input and/or output. [Default is (longitude,latitude)]. Append i to select input only or o to select output only. [Default affects both].
| −bi |  | Selects binary input. Append s for single precision [Default is d (double)]. Uppercase S or D will force byte-swapping. Optionally, append ncol, the number of columns in your binary input file if it exceeds the columns needed by the program. Or append c if the input file is netCDF. Optionally, append var1/var2/... to specify the variables to be read. [Default is 2 input columns].
| −bo |  | Selects binary output. Append s for single precision [Default is d (double)]. Uppercase S or D will force byte-swapping. Optionally, append ncol, the number of desired columns in your binary output file. [Default is same as input]. Node ids are stored as binary 4-byte integer triplets. −bo is ignored if −M is selected.

−f

Special formatting 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. Append T (absolute calendar time), t (relative time in chosen TIME_UNIT since TIME_EPOCH), x (longitude), y (latitude), or f (floating point) to each column or column range item. Shorthand −f[i|o]g means −f[i|o]0x,1y (geographic coordinates).

## ASCII FORMAT PRECISION

The ASCII output formats of numerical data are controlled by parameters in your .gmtdefaults4 file. Longitude and latitude are formatted according to OUTPUT_DEGREE_FORMAT, whereas other values are formatted according to D_FORMAT. 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 D_FORMAT setting.

## GRID VALUES PRECISION

Regardless of the precision of the input data, GMT programs that create gridded files will internally hold the grids in 4-byte floating point arrays. This is done to conserve memory and futhermore most if not all real data can be stored using 4-byte floating point values. Data with higher precision (i.e., double precision values) will lose that precision once GMT operates on the grid or writes out new grids. To limit loss of precision when processing data you should always consider normalizing the data prior to processing.

## 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

triangulate samples.xyz −bo −R0/30/0/30 −I2 −Gsurf.grd > samples.ijk

To draw the optimal Delauney triangulation network based on the same file using a 15-cm-wide Mercator map, use

triangulate samples.xyz −M −R-100/-90/30/34 −JM15c | psxy −M −R-100/-90/30/34 −JM15c −W0.5p −B1 > network.ps

## SEE ALSO

GMT(1), pscontour(1)

## 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.
www.cs.cmu.edu/~quake/triangle.html