.\" Man page generated from reStructuredText. . .TH "TRIANGULATE" "1gmt" "Jan 10, 2019" "5.4.5" "GMT" .SH NAME triangulate \- Do optimal (Delaunay) triangulation and gridding of Cartesian table data [method] . .nr rst2man-indent-level 0 . .de1 rstReportMargin \\$1 \\n[an-margin] level \\n[rst2man-indent-level] level margin: \\n[rst2man-indent\\n[rst2man-indent-level]] - \\n[rst2man-indent0] \\n[rst2man-indent1] \\n[rst2man-indent2] .. .de1 INDENT .\" .rstReportMargin pre: . RS \\$1 . nr rst2man-indent\\n[rst2man-indent-level] \\n[an-margin] . nr rst2man-indent-level +1 .\" .rstReportMargin post: .. .de UNINDENT . RE .\" indent \\n[an-margin] .\" old: \\n[rst2man-indent\\n[rst2man-indent-level]] .nr rst2man-indent-level -1 .\" new: \\n[rst2man-indent\\n[rst2man-indent-level]] .in \\n[rst2man-indent\\n[rst2man-indent-level]]u .. .SH SYNOPSIS .sp \fBtriangulate\fP [ \fItable\fP ] [ \fB\-C\fP\fIslpfile\fP ] [ \fB\-D\fP\fBx\fP|\fBy\fP ] [ \fB\-E\fP\fIempty\fP ] [ \fB\-G\fP\fIgrdfile\fP ] [ \fB\-I\fP\fIincrement\fP ] [ \fB\-J\fP\fIparameters\fP ] [ \fB\-M\fP ] [ \fB\-N\fP ] [ \fB\-Q\fP[\fBn\fP] ] [ \fB\-R\fP\fIregion\fP ] [ \fB\-S\fP ] [ \fB\-V\fP[\fIlevel\fP] ] [ \fB\-Z\fP ] [ \fB\-b\fPbinary ] [ \fB\-d\fPnodata ] [ \fB\-e\fPregexp ] [ \fB\-f\fPflags ] [ \fB\-h\fPheaders ] [ \fB\-i\fPflags ] [ \fB\-r\fP ] [ \fB\-:\fP[\fBi\fP|\fBo\fP] ] .sp \fBNote:\fP No space is allowed between the option flag and the associated arguments. .SH DESCRIPTION .sp \fBtriangulate\fP reads one or more ASCII [or binary] files (or standard input) containing x,y[,z] and performs Delaunay triangulation, i.e., it find how the points should be connected to give the most equilateral triangulation possible. If a map projection (give \fB\-R\fP and \fB\-J\fP) 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 \fB\-G\fP \fB\-I\fP 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 \fBtriangulate \-\fP to see which method is selected). This choice is made during the GMT installation. Furthermore, if the Shewchuk algorithm is installed then you can also perform the calculation of Voronoi polygons and optionally grid your data via the natural nearest neighbor algorithm. .SH REQUIRED ARGUMENTS .sp None. .SH OPTIONAL ARGUMENTS .INDENT 0.0 .TP .B \fItable\fP One or more ASCII (or binary, see \fB\-bi\fP[\fIncols\fP][\fItype\fP]) data table file(s) holding a number of data columns. If no tables are given then we read from standard input. .UNINDENT .INDENT 0.0 .TP \fB\-C\fP\fIslpfile\fP .INDENT 7.0 .TP .B Read a slope grid (in radians) and compute the propagated uncertainty in the bathymetry using the CURVE algorithm [Zambo et al, 20xx]. Requires the \fB\-G\fP option to specify the output grid. Note that the \fIslpgrid\fP sets the domain for the output grid so \fB\-R\fP, \fB\-I\fP, [\fB\-r\fP] are not required. Cannot be used in conjunction with \fB\-D\fP, \fB\-F\fP, \fB\-M\fP, \fB\-N\fP, \fB\-Q\fP, \fB\-S\fP and \fB\-T\fP\&. .UNINDENT .UNINDENT .INDENT 0.0 .TP \fB\-Dx\fP|\fBy\fP Take either the \fIx\fP\- or \fIy\fP\-derivatives of surface represented by the planar facets (only used when \fB\-G\fP is set). .UNINDENT .INDENT 0.0 .TP \fB\-E\fP\fIempty\fP Set the value assigned to empty nodes when \fB\-G\fP is set [NaN]. .UNINDENT .INDENT 0.0 .TP \fB\-G\fP\fIgrdfile\fP Use triangulation to grid the data onto an even grid (specified with \fB\-R\fP \fB\-I\fP). 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 \fBtriangulate\fP (this is true of all gridding routines) or instead select \fBsphtriangulate\fP\&. For natural nearest neighbor gridding you must add \fB\-Qn\fP\&. .UNINDENT .INDENT 0.0 .TP \fB\-I\fP\fIxinc\fP[\fIunit\fP][\fB+e\fP|\fBn\fP][/\fIyinc\fP[\fIunit\fP][\fB+e\fP|\fBn\fP]] \fIx_inc\fP [and optionally \fIy_inc\fP] is the grid spacing. Optionally, append a suffix modifier. \fBGeographical (degrees) coordinates\fP: Append \fBm\fP to indicate arc minutes or \fBs\fP to indicate arc seconds. If one of the units \fBe\fP, \fBf\fP, \fBk\fP, \fBM\fP, \fBn\fP or \fBu\fP is appended instead, the increment is assumed to be given in meter, foot, km, Mile, nautical mile or US survey foot, respectively, and will be converted to the equivalent degrees longitude at the middle latitude of the region (the conversion depends on PROJ_ELLIPSOID). If \fIy_inc\fP is given but set to 0 it will be reset equal to \fIx_inc\fP; otherwise it will be converted to degrees latitude. \fBAll coordinates\fP: If \fB+e\fP is appended then the corresponding max \fIx\fP (\fIeast\fP) or \fIy\fP (\fInorth\fP) may be slightly adjusted to fit exactly the given increment [by default the increment may be adjusted slightly to fit the given domain]. Finally, instead of giving an increment you may specify the \fInumber of nodes\fP desired by appending \fB+n\fP to the supplied integer argument; the increment is then recalculated from the number of nodes and the domain. The resulting increment value depends on whether you have selected a gridline\-registered or pixel\-registered grid; see App\-file\-formats for details. Note: if \fB\-R\fP\fIgrdfile\fP is used then the grid spacing has already been initialized; use \fB\-I\fP to override the values. .UNINDENT .INDENT 0.0 .TP \fB\-J\fP\fIparameters\fP (more ...) Select map projection. .UNINDENT .INDENT 0.0 .TP \fB\-M\fP Output triangulation network as multiple line segments separated by a segment header record. .UNINDENT .INDENT 0.0 .TP \fB\-N\fP Used in conjunction with \fB\-G\fP to also write the triplets of the ids of all the Delaunay vertices [Default only writes the grid]. .UNINDENT .INDENT 0.0 .TP \fB\-Q\fP[\fBn\fP] Output the edges of the Voronoi cells instead [Default is Delaunay triangle edges]. Requires \fB\-R\fP and is only available if linked with the Shewchuk [1996] library. Note that \fB\-Z\fP is ignored on output. Optionally, append \fBn\fP for combining the edges into closed Voronoi polygons. .UNINDENT .INDENT 0.0 .TP \fB\-R\fP\fIxmin\fP/\fIxmax\fP/\fIymin\fP/\fIymax\fP[\fB+r\fP][\fB+u\fP\fIunit\fP] (more ...) Specify the region of interest. .UNINDENT .INDENT 0.0 .TP \fB\-S\fP Output triangles as polygon segments separated by a segment header record. Requires Delaunay triangulation. .UNINDENT .INDENT 0.0 .TP \fB\-T\fP Output edges or polygons even if gridding has been selected with the \fB\-G\fP option [Default will not output the triangulation or Voronoi polygons is gridding is selected]. .UNINDENT .INDENT 0.0 .TP \fB\-V\fP[\fIlevel\fP] (more ...) Select verbosity level [c]. .UNINDENT .INDENT 0.0 .TP \fB\-Z\fP Controls whether we read (x,y) or (x,y,z) data and if z should be output when \fB\-M\fP or \fB\-S\fP are used [Read (x,y) only]. .UNINDENT .INDENT 0.0 .TP \fB\-bi\fP[\fIncols\fP][\fBt\fP] (more ...) Select native binary input. [Default is 2 input columns]. .UNINDENT .INDENT 0.0 .TP \fB\-bo\fP[\fIncols\fP][\fItype\fP] (more ...) Select native binary output. [Default is same as input]. Node ids are stored as double triplets. .UNINDENT .INDENT 0.0 .TP \fB\-d\fP[\fBi\fP|\fBo\fP]\fInodata\fP (more ...) Replace input columns that equal \fInodata\fP with NaN and do the reverse on output. .UNINDENT .INDENT 0.0 .TP \fB\-e\fP[\fB~\fP]\fI"pattern"\fP \fB|\fP \fB\-e\fP[\fB~\fP]/\fIregexp\fP/[\fBi\fP] (more ...) Only accept data records that match the given pattern. .UNINDENT .INDENT 0.0 .TP \fB\-f\fP[\fBi\fP|\fBo\fP]\fIcolinfo\fP (more ...) Specify data types of input and/or output columns. .UNINDENT .INDENT 0.0 .TP \fB\-h\fP[\fBi\fP|\fBo\fP][\fIn\fP][\fB+c\fP][\fB+d\fP][\fB+r\fP\fIremark\fP][\fB+r\fP\fItitle\fP] (more ...) Skip or produce header record(s). .UNINDENT .INDENT 0.0 .TP \fB\-i\fP\fIcols\fP[\fB+l\fP][\fB+s\fP\fIscale\fP][\fB+o\fP\fIoffset\fP][,\fI\&...\fP] (more ...) Select input columns and transformations (0 is first column). .UNINDENT .INDENT 0.0 .TP \fB\-r\fP (more ...) Set pixel node registration [gridline]. (Only valid with \fB\-G\fP). .UNINDENT .INDENT 0.0 .TP \fB\-:\fP[\fBi\fP|\fBo\fP] (more ...) Swap 1st and 2nd column on input and/or output. .UNINDENT .INDENT 0.0 .TP \fB\-^\fP or just \fB\-\fP Print a short message about the syntax of the command, then exits (NOTE: on Windows just use \fB\-\fP). .TP \fB\-+\fP or just \fB+\fP Print an extensive usage (help) message, including the explanation of any module\-specific option (but not the GMT common options), then exits. .TP \fB\-?\fP or no arguments Print a complete usage (help) message, including the explanation of all options, then exits. .UNINDENT .SH ASCII FORMAT PRECISION .sp 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 (\fB\-bo\fP if available) or specify more decimals using the FORMAT_FLOAT_OUT setting. .SH GRID VALUES PRECISION .sp Regardless of the precision of the input data, GMT programs that create grid files will internally hold the grids in 4\-byte floating point arrays. This is done to conserve memory and furthermore 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. .SH EXAMPLES .sp 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 .INDENT 0.0 .INDENT 3.5 .INDENT 0.0 .INDENT 3.5 .sp .nf .ft C gmt triangulate samples.xyz \-bo \-R0/30/0/30 \-I2 \-Gsurf.nc > samples.ijk .ft P .fi .UNINDENT .UNINDENT .UNINDENT .UNINDENT .sp To draw the optimal Delaunay triangulation network based on the same file using a 15\-cm\-wide Mercator map, use .INDENT 0.0 .INDENT 3.5 .INDENT 0.0 .INDENT 3.5 .sp .nf .ft C gmt triangulate samples.xyz \-M \-R\-100/\-90/30/34 \-JM15c | gmt psxy \e \-R\-100/\-90/30/34 \-JM15c \-W0.5p \-B1 > network.ps .ft P .fi .UNINDENT .UNINDENT .UNINDENT .UNINDENT .sp To instead plot the Voronoi cell outlines, try .INDENT 0.0 .INDENT 3.5 .INDENT 0.0 .INDENT 3.5 .sp .nf .ft C gmt triangulate samples.xyz \-M \-Q \-R\-100/\-90/30/34 \-JM15c | \e gmt psxy \-R\-100/\-90/30/34 \-JM15c \-W0.5p \-B1 > cells.ps .ft P .fi .UNINDENT .UNINDENT .UNINDENT .UNINDENT .sp To combine the Voronoi outlines into polygons and paint them according to their ID, try .INDENT 0.0 .INDENT 3.5 .INDENT 0.0 .INDENT 3.5 .sp .nf .ft C gmt triangulate samples.xyz \-M \-Qn \-R\-100/\-90/30/34 \-JM15c | \e gmt psxy \-R\-100/\-90/30/34 \-JM15c \-W0.5p+cf \-L \-B1 \-Ccolors.cpt \-L > polygons.ps .ft P .fi .UNINDENT .UNINDENT .UNINDENT .UNINDENT .sp To grid the data using the natural nearest neighbor algorithm, try .INDENT 0.0 .INDENT 3.5 .INDENT 0.0 .INDENT 3.5 .sp .nf .ft C gmt triangulate samples.xyz \-Gnnn.nc \-Qn \-R\-100/\-90/30/34 \-I0.5 .ft P .fi .UNINDENT .UNINDENT .UNINDENT .UNINDENT .SH NOTES .sp The uncertainty propagation for bathymetric grids requires both horizontal and vertical uncertainties and these are weighted given the local slope. See the references for more details. .SH SEE ALSO .sp gmt, greenspline, nearneighbor, pscontour, sphdistance, sphinterpolate, sphtriangulate, surface .SH REFERENCES .sp Watson, D. F., 1982, Acord: Automatic contouring of raw data, \fIComp. & Geosci.\fP, \fB8\fP, 97\-101. .sp 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. .sp \fI\%Shewchuk\(aqs Homepage\fP .SH COPYRIGHT 2019, P. Wessel, W. H. F. Smith, R. Scharroo, J. Luis, and F. Wobbe .\" Generated by docutils manpage writer. .