NAME¶
sphtriangulate - Perform optimal Delaunay triangulation or Voronoi construction
of spherical data
SYNOPSIS¶
sphtriangulate infiles [
-A ] [
-C ] [
-D ] [
-H[
i][
nrec] ] [
-Lunit ] [
-Nnfile ] [
-Qd|
v ] [
-T ] [
-V ] [
-:[
i|
o] ] [
-b[
i|
o][
s|
S|
d|
D[
ncol]|
c[
var1/...]]
] [
-m[
i|
o][
flag] ]
DESCRIPTION¶
sphtriangulate reads one or more ASCII [or binary] files (or standard
input) containing lon, lat and performs a spherical Delaunay triangulation,
i.e., it find how the points should be connected to give the most equilateral
triangulation possible on the sphere. Optionally, you may choose
-Qv
which will do further processing to obtain the Voronoi polygons. Normally,
either set of polygons will be written as fillable multi-segment output; use
-T to write unique arcs instead. As an option, compute the area of each
triangle or polygon. The algorithm used is STRIPACK.
- infiles
- Data files with the point coordinates in ASCII (or binary;
see -b). If no files are given the standard input is read.
OPTIONS¶
- -A
- Compute the area of the spherical triangles (-Qd) or
polygons ( -Qv) and write the areas (in chosen units; see
-L) in the multisegment output headers [no areas calculated].
- -C
- For large data set you can save some memory (at the expense
of more processing) by only storing one form of location coordinates
(geographic or Cartesian 3-D vectors) at any given time, translating from
one form to the other when necessary [Default keeps both arrays in
memory].
- -D
- Used with -m to skip the last (repeated) input
vertex at the end of a closed segment if it equals the first point in the
segment. Requires -m [Default uses all points].
- -H
- Input file(s) has header record(s). If used, the default
number of header records is N_HEADER_RECS. 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.
- -L
- Specify the unit used for distance and area calculations.
Choose among e (m), k (km), m (mile), n
(nautical mile), or d (spherical degree). A spherical approximation
is used unless ELLIPSOID is set to an actual ellipsoid. When degree
is selected the areas are given in steradians.
- -N
- Write the information pertaining to each polygon (for
Delaunay: the three node number and the triangle area; for Voronoi the
unique node lon, lat and polygon area) to a separate file [Default puts
this information in the segment headers of the output file]. Required if
binary output is needed.
- -Q
- Select between BD(d)elaunay or BD(v)oronoi mode
[Delaunay].
- -T
- Write the unique arcs of the construction [Default writes
fillable triangles or polygons]. When used with -A we store arc
length in the segment header in chosen unit (see -L).
- -V
- Selects verbose mode, which will send progress reports to
stderr [Default runs "silently"].
- -:
- 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].
- -m
- Multiple segment file(s). Segments are separated by a
special record. For ASCII files the first character must be flag
[Default is '>']. For binary files all fields must be NaN and -b
must set the number of output columns explicitly. By default the -m
setting applies to both input and output. Use -mi and -mo to
give separate settings to input and output.
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 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.
EXAMPLES¶
To triangulate the points in the file testdata.txt, and make a Voronoi diagram
via
psxy, use
sphtriangulate testdata.txt
-Qv | psxy
-Rg -JG30/30/6i
-M -L -P -W1p
-B0g30 | gv -
To compute the optimal Delaunay triangulation network based on the multiple
segment file globalnodes.d and save the area of each triangle in the header
record, try
sphtriangulate globalnodes.d
-M -Qd -A > global_tri.d
SEE ALSO¶
GMT(1),
triangulate(1) sphinterpolate(1)
sphdistance(1)
REFERENCES¶
Renka, R, J., 1997, Algorithm 772: STRIPACK: Delaunay Triangulation and Voronoi
Diagram on the Surface of a Sphere,
AMC Trans. Math. Software, 23 (3),
416-434.