## NAME

           triangulate - Perform optimal Delauney triangulation and gridding

## SYNOPSIS

           triangulate  infiles [ -Dx|y ] [ -Eempty ] [ -Ggrdfile ] [ -H[nrec] ] [
           -Ix_inc[m|c][/y_inc[m|c]]  ]  [  -Jparameters  ]   [   -M[flag]   ]   [
           -Rwest/east/south/north[r]  ]  [  -V  ]  [  -Z ] [ -: ] [ -bi[s][n] ] [
           -bo[s][n] ] [ -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  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 writ-
           ten 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 seg-
           ment file that can be piped through psxy to draw the triangulation net-
           work.  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  tri-
           angulations  is  either  that  of  Watson  [1982] [Default] or Shewchuk
           [1996] (if installed).  This choice is made during  the  GMT  installa-
           tion.

           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  pro-
                  jecting  all data to a local coordinate system before using tri-
                  angulate (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].

           -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.  For map height, max  dimension,  or  min
                  dimension, append h, +, or - to the width, respectively.

                  CYLINDRICAL PROJECTIONS:

                  -Jclon0/lat0/scale (Cassini)
                  -Jjlon0/scale (Miller)
                  -Jmscale (Mercator - Greenwich and Equator as origin)
                  -Jmlon0/lat0/scale (Mercator - Give meridian and standard paral-
                  lel)
                  -Joalon0/lat0/azimuth/scale  (Oblique  Mercator  -   point   and
                  azimuth)
                  -Joblon0/lat0/lon1/lat1/scale (Oblique Mercator - two points)
                  -Joclon0/lat0/lonp/latp/scale  (Oblique  Mercator  -  point  and
                  pole)
                  -Jqlon0/scale (Equidistant Cylindrical  Projection  (Plate  Car-
                  ree))
                  -Jtlon0/scale (TM - Transverse Mercator, with Equator as y = 0)
                  -Jtlon0/lat0/scale (TM - Transverse Mercator, set origin)
                  -Juzone/scale (UTM - Universal Transverse Mercator)
                  -Jylon0/lats/scale (Basic Cylindrical Projection)

                  AZIMUTHAL PROJECTIONS:

                  -Jalon0/lat0/scale (Lambert).
                  -Jelon0/lat0/scale (Equidistant).
                  -Jflon0/lat0/horizon/scale (Gnomonic).
                  -Jglon0/lat0/scale (Orthographic).
                  -Jslon0/lat0/[slat/]scale (General Stereographic)

                  CONIC PROJECTIONS:

                  -Jblon0/lat0/lat1/lat2/scale (Albers)
                  -Jdlon0/lat0/lat1/lat2/scale (Equidistant)
                  -Jllon0/lat0/lat1/lat2/scale (Lambert)

                  MISCELLANEOUS PROJECTIONS:

                  -Jhlon0/scale (Hammer)
                  -Jilon0/scale (Sinusoidal)
                  -Jk[f|s]lon0/scale (Eckert IV (f) and VI (s))
                  -Jnlon0/scale (Robinson)
                  -Jrlon0/scale (Winkel Tripel)
                  -Jvlon0/scale (Van der Grinten)
                  -Jwlon0/scale (Mollweide)

                  NON-GEOGRAPHICAL PROJECTIONS:

                  -Jp[a]scale[/origin]  (polar  (theta,r)  coordinates, optional a
                  for azimuths and offset theta [0])
                  -Jxx-scale[l|ppow][/y-scale[l|ppow]][d] (Linear, log, and  power
                  scaling)
                  More details can be found in the psbasemap man pages.

           -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 wesn. The
                  two shorthands  -Rg  -Rd  stand  for  global  domain  (0/360  or
                  -180/+180  in longitude respectively, with -90/+90 in latitude).
                  For calendar time coordinates you may either give relative  time
                  (relative  to  the  selected  TIME_EPOCH  and  in  the  selected
                  TIME_UNIT; append t to -JX|x), or  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 as indicated  (however,  input/output
                  and plotting formats are flexible).

           -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
                  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].   Append  n  for  the  number  of columns in the binary
                  file(s).
                  Node ids are stored as binary 4-byte integer  triplets.  -bo  is
                  ignored if -M is selected.

           -f     Special  formatting  of  input  and output columns (time or geo-
                  graphical data) Specify i(nput) or  o(utput)  [Default  is  both
                  input  and output].  Give one or more columns (or column ranges)
                  separated by commas.  Append T (Absolute calendar time), t (time
                  relative  to  chosen TIME_EPOCH), x (longitude), y (latitude), g
                  (geographic coordinate), or f (floating point) to each column or
                  column range item.

## 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(l), pscontour(l)

## 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  Genera-
           tor  and Delaunay Triangulator, First Workshop on Applied Computational
           Geometry (Philadelphia, PA), 124-133, ACM, May 1996.
           www.cs.cmu.edu/~quake/triangle.html

    GMT4.0                            1 Oct 2004                    TRIANGULATE(l)