# man triangulate () - Perform optimal Delauney triangulation and gridding

## NAME

triangulate - Perform optimal Delauney triangulation and gridding

## SYNOPSIS

**triangulate** *infiles* [ **-Dx|y** ] [ **-E***empty* ] [ **-G***grdfile* ]
[ **-H**[*nrec*] ] [ **-I***x_inc*[**m|c**][/*y_inc*[**m|c**]] ] [ **-J***parameters* ]
[ **-L** ] [ **-M**[*flag*] ]
[ **-R***west/east/south/north*[**r**] ] [ **-V** ] [ **-Z** ] [ **-:** ]
[ **-bi**[**s**][*n*] ] [ **-bo**[**s**][*n*] ]

## 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 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 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 Shewchuck [1996] (if installed).
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]. **-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 .gmtdefaults file. If used,
**GMT**default is 1 header record. **-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 .gmtdefaults, but this can be
overridden on the command line by appending the c, i, or m to the scale/width value.

**CYLINDRICAL PROJECTIONS:**

**-Jc***lon0/lat0/scale*(Cassini)

**-Jj***lon0/scale*(Miller)

**-Jm***scale*(Mercator - Greenwich and Equator as origin)

**-Jm***lon0/lat0/scale*(Mercator - Give meridian and standard parallel)

**-Joa***lon0/lat0/azimuth/scale*(Oblique Mercator - point and azimuth)

**-Job***lon0/lat0/lon1/lat1/scale*(Oblique Mercator - two points)

**-Joc***lon0/lat0/lonp/latp/scale*(Oblique Mercator - point and pole)

**-Jq***lon0/scale*(Equidistant Cylindrical Projection (Plate Carree))

**-Jt***lon0/scale*(TM - Transverse Mercator, with Equator as y = 0)

**-Jt***lon0/lat0/scale*(TM - Transverse Mercator, set origin)

**-Ju***zone/scale*(UTM - Universal Transverse Mercator)

**-Jy***lon0/lats/scale*(Basic Cylindrical Projection)

**AZIMUTHAL PROJECTIONS:**

**-Ja***lon0/lat0/scale*(Lambert).

**-Je***lon0/lat0/scale*(Equidistant).

**-Jf***lon0/lat0/horizon/scale*(Gnomonic).

**-Jg***lon0/lat0/scale*(Orthographic).

**-Js***lon0/lat0/*[*slat/*]*scale*(General Stereographic)

**CONIC PROJECTIONS:**

**-Jb***lon0/lat0/lat1/lat2/scale*(Albers)

**-Jd***lon0/lat0/lat1/lat2/scale*(Equidistant)

**-Jl***lon0/lat0/lat1/lat2/scale*(Lambert)

**MISCELLANEOUS PROJECTIONS:**

**-Jh***lon0/scale*(Hammer)

**-Ji***lon0/scale*(Sinusoidal)

**-Jk**[**f|s**]*lon0/scale*(Eckert IV (f) and VI (s))

**-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*] (polar (theta,r) coordinates, optional**a**for azimuths and offset theta [0])

**-Jx***x-scale*[**l|p***pow*][*/y-scale*[**l|p***pow*]] (Linear, log, and power scaling)

More details can be found in the**psbasemap**manpages.

**-L**- Indicates that the x column contains longitudes, which may differ from the region
in
**-R**by [multiples of] 360 degrees [Default assumes no periodicity]. **-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***west, east, south,*and*north*specify the Region of interest. To specify boundaries in degrees and minutes [and seconds], use the dd:mm[:ss] format. Append**r**if lower left and upper right map coordinates are given instead of wesn.**-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/output. [Default is (longitude,latitude)]. Applies to geographic coordinates only.
**-bi**- Selects binary input. Append
**s**for single precision [Default is double]. Append*n*for the number of columns in the binary file(s). [Default is 2 input columns]. **-bo**- Selects binary output. Append
**s**for single precision [Default is double]. Node ids are stored as binary 4-byte integer triplets.**-bo**is ignored if**-M**is selected.

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

triangulate samples.xyz **-bo** **-R**0/30/0/30 **-I**2 **-G**surf.grd > samples.ijk

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

triangulate samples.xyz **-M -R**-100/-90/30/34 **-JM**15**c** | psxy **-M -R**-100/-90/30/34 **-JM**15**c**
**-W**0.5**p** **-B**1 > network.ps

## SEE ALSO

## REFERENCES

Watson, D. F., 1982, Acord: Automatic contouring of raw data, *Comp. & Geosci., 8*, 97-101.

Shewchuck, 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