1SPHTRIANGULATE(1) Generic Mapping Tools SPHTRIANGULATE(1)
2
3
4
6 sphtriangulate - Perform optimal Delaunay triangulation or Voronoi con‐
7 struction of spherical data
8
10 sphtriangulate infiles [ -A ] [ -C ] [ -D ] [ -H[i][nrec] ] [ -Lunit ]
11 [ -Nnfile ] [ -Qd|v ] [ -T ] [ -V ] [ -:[i|o] ] [
12 -b[i|o][s|S|d|D[ncol]|c[var1/...]] ] [ -m[i|o][flag] ]
13
15 sphtriangulate reads one or more ASCII [or binary] files (or standard
16 input) containing lon, lat and performs a spherical Delaunay triangula‐
17 tion, i.e., it find how the points should be connected to give the most
18 equilateral triangulation possible on the sphere. Optionally, you may
19 choose -Qv which will do further processing to obtain the Voronoi poly‐
20 gons. Normally, either set of polygons will be written as fillable
21 multi-segment output; use -T to write unique arcs instead. As an
22 option, compute the area of each triangle or polygon. The algorithm
23 used is STRIPACK.
24
25 infiles
26 Data files with the point coordinates in ASCII (or binary; see
27 -b). If no files are given the standard input is read.
28
30 -A Compute the area of the spherical triangles (-Qd) or polygons
31 (-Qv) and write the areas (in chosen units; see -L) in the mul‐
32 tisegment output headers [no areas calculated].
33
34 -C For large data set you can save some memory (at the expense of
35 more processing) by only storing one form of location coordi‐
36 nates (geographic or Cartesian 3-D vectors) at any given time,
37 translating from one form to the other when necessary [Default
38 keeps both arrays in memory].
39
40 -D Used with -m to skip the last (repeated) input vertex at the end
41 of a closed segment if it equals the first point in the segment.
42 Requires -m [Default uses all points].
43
44 -H Input file(s) has header record(s). If used, the default number
45 of header records is N_HEADER_RECS. Use -Hi if only input data
46 should have header records [Default will write out header
47 records if the input data have them]. Blank lines and lines
48 starting with # are always skipped.
49
50 -L Specify the unit used for distance and area calculations.
51 Choose among e (m), k (km), m (mile), n (nautical mile), or d
52 (spherical degree). A spherical approximation is used unless
53 ELLIPSOID is set to an actual ellipsoid. When degree is
54 selected the areas are given in steradians.
55
56 -N Write the information pertaining to each polygon (for Delaunay:
57 the three node number and the triangle area; for Voronoi the
58 unique node lon, lat and polygon area) to a separate file
59 [Default puts this information in the segment headers of the
60 output file]. Required if binary output is needed.
61
62 -Q Select between BD(d)elaunay or BD(v)oronoi mode [Delaunay].
63
64 -T Write the unique arcs of the construction [Default writes fill‐
65 able triangles or polygons]. When used with -A we store arc
66 length in the segment header in chosen unit (see -L).
67
68 -V Selects verbose mode, which will send progress reports to stderr
69 [Default runs "silently"].
70
71 -: Toggles between (longitude,latitude) and (latitude,longitude)
72 input and/or output. [Default is (longitude,latitude)]. Append
73 i to select input only or o to select output only. [Default
74 affects both].
75
76 -bi Selects binary input. Append s for single precision [Default is
77 d (double)]. Uppercase S or D will force byte-swapping.
78 Optionally, append ncol, the number of columns in your binary
79 input file if it exceeds the columns needed by the program. Or
80 append c if the input file is netCDF. Optionally, append
81 var1/var2/... to specify the variables to be read. [Default is
82 2 input columns].
83
84 -bo Selects binary output. Append s for single precision [Default
85 is d (double)]. Uppercase S or D will force byte-swapping.
86 Optionally, append ncol, the number of desired columns in your
87 binary output file. [Default is same as input].
88
89 -m Multiple segment file(s). Segments are separated by a special
90 record. For ASCII files the first character must be flag
91 [Default is '>']. For binary files all fields must be NaN and
92 -b must set the number of output columns explicitly. By default
93 the -m setting applies to both input and output. Use -mi and
94 -mo to give separate settings to input and output.
95
97 The ASCII output formats of numerical data are controlled by parameters
98 in your .gmtdefaults4 file. Longitude and latitude are formatted
99 according to OUTPUT_DEGREE_FORMAT, whereas other values are formatted
100 according to D_FORMAT. Be aware that the format in effect can lead to
101 loss of precision in the output, which can lead to various problems
102 downstream. If you find the output is not written with enough preci‐
103 sion, consider switching to binary output (-bo if available) or specify
104 more decimals using the D_FORMAT setting.
105
107 Regardless of the precision of the input data, GMT programs that create
108 grid files will internally hold the grids in 4-byte floating point
109 arrays. This is done to conserve memory and furthermore most if not
110 all real data can be stored using 4-byte floating point values. Data
111 with higher precision (i.e., double precision values) will lose that
112 precision once GMT operates on the grid or writes out new grids. To
113 limit loss of precision when processing data you should always consider
114 normalizing the data prior to processing.
115
117 To triangulate the points in the file testdata.txt, and make a Voronoi
118 diagram via psxy, use
119
120 sphtriangulate testdata.txt -Qv | psxy -Rg -JG30/30/6i -M -L -P -W1p
121 -B0g30 | gv -
122
123 To compute the optimal Delaunay triangulation network based on the mul‐
124 tiple segment file globalnodes.d and save the area of each triangle in
125 the header record, try
126
127 sphtriangulate globalnodes.d -M -Qd -A > global_tri.d
128
130 GMT(1), triangulate(1) sphinterpolate(1) sphdistance(1)
131
133 Renka, R, J., 1997, Algorithm 772: STRIPACK: Delaunay Triangulation and
134 Voronoi Diagram on the Surface of a Sphere, AMC Trans. Math. Software,
135 23 (3), 416-434.
136
137
138
139GMT 4.5.6 10 Mar 2011 SPHTRIANGULATE(1)