1SPHDISTANCE(1)                        GMT                       SPHDISTANCE(1)
2
3
4

NAME

6       sphdistance  - Make Voronoi distance, node, or nearest-neighbor grid on
7       a sphere
8

SYNOPSIS

10       sphdistance [ table ]  -Ggrdfile [  -C ] [  -Ed|n|z[dist] ] [  -Iincre‐
11       ment  ] [  -Lunit ] [  -Nnodetable ] [  -Qvoronoi.txt ] [  -Rregion ] [
12       -V[level] ] [ -bbinary ] [ -dnodata ] [ -eregexp  ]  [  -hheaders  ]  [
13       -iflags ] [ -r ] [ -:[i|o] ]
14
15       Note:  No  space  is allowed between the option flag and the associated
16       arguments.
17

DESCRIPTION

19       sphdistance reads one or more ASCII  [or  binary]  files  (or  standard
20       input)  containing  lon,  lat  and performs the construction of Voronoi
21       polygons. These polygons are then processed to  calculate  the  nearest
22       distance to each node of the lattice and written to the specified grid.
23       The Voronoi algorithm used is STRIPACK. As an option, you  may  provide
24       pre-calculated  Voronoi polygon file in the format written by sphtrian‐
25       gulate, thus bypassing the memory-  and  time-consuming  triangulariza‐
26       tion.
27

REQUIRED ARGUMENTS

29       -Ggrdfile
30              Name  of the output grid to hold the computed distances (but see
31              -E for other node value options).
32

OPTIONAL ARGUMENTS

34       table  One or more ASCII (or binary, see -bi[ncols][type])  data  table
35              file(s) holding a number of data columns. If no tables are given
36              then we read from standard input.
37
38       -C     For large data sets you can save some memory (at the expense  of
39              more  processing)  by  only storing one form of location coordi‐
40              nates (geographic or Cartesian 3-D vectors) at any  given  time,
41              translating  from  one form to the other when necessary [Default
42              keeps both arrays in memory]. Not applicable with -Q.
43
44       -Ed|n|z[dist]
45              Specify the quantity that should be assigned to the grid  nodes.
46              By default we compute distances to the nearest data point [-Ed].
47              Use -En to assign the ID numbers of the  Voronoi  polygons  that
48              each  grid  node  is  inside,  or  use  -Ez  for a natural near‐
49              est-neighbor grid where we assign all nodes inside  the  polygon
50              the  z-value  of the center node.  Optionally, append the resam‐
51              pling interval along Voronoi arcs in spherical degrees [1].
52
53       -Ixinc[unit][+e|n][/yinc[unit][+e|n]]
54              x_inc [and optionally y_inc] is the  grid  spacing.  Optionally,
55              append  a  suffix  modifier. Geographical (degrees) coordinates:
56              Append m to indicate arc minutes or s to indicate  arc  seconds.
57              If  one of the units e, f, k, M, n or u is appended instead, the
58              increment is assumed to be given in meter, foot, km, Mile,  nau‐
59              tical  mile  or  US  survey foot, respectively, and will be con‐
60              verted to the equivalent degrees longitude at the  middle  lati‐
61              tude  of  the region (the conversion depends on PROJ_ELLIPSOID).
62              If y_inc is given but set to 0 it will be reset equal to  x_inc;
63              otherwise  it will be converted to degrees latitude. All coordi‐
64              nates: If +e is appended then the corresponding max x (east)  or
65              y  (north)  may  be  slightly  adjusted to fit exactly the given
66              increment [by default the increment may be adjusted slightly  to
67              fit  the  given domain]. Finally, instead of giving an increment
68              you may specify the number of nodes desired by appending  +n  to
69              the  supplied  integer  argument; the increment is then recalcu‐
70              lated from the number of nodes and  the  domain.  The  resulting
71              increment  value  depends  on  whether you have selected a grid‐
72              line-registered or pixel-registered grid;  see  App-file-formats
73              for  details.  Note:  if -Rgrdfile is used then the grid spacing
74              has already been initialized; use -I to override the values.
75
76       -Lunit Specify the unit used for distance calculations. Choose among  d
77              (spherical degree), e (m), f (feet), k (km), M (mile), n (nauti‐
78              cal mile) or u survey foot. A spherical  approximation  is  used
79              unless PROJ_ELLIPSOID is set to an actual ellipsoid.
80
81       -Nnodetable
82              Read  the  information  pertaining  to each Voronoi polygon (the
83              unique node lon, lat and polygon  area)  from  a  separate  file
84              [Default  acquires this information from the ASCII segment head‐
85              ers of the output file]. Required if  binary  input  via  -Q  is
86              used.
87
88       -Qvoronoi.txt
89              Append  the  name of a file with pre-calculated Voronoi polygons
90              [Default performs the Voronoi construction on input  data].  For
91              binary data -bi you must specify the node information separately
92              (via -N).
93
94       -Rwest/east/south/north[/zmin/zmax][+r][+uunit]
95              west, east, south, and north specify the region of interest, and
96              you    may    specify    them   in   decimal   degrees   or   in
97              [±]dd:mm[:ss.xxx][W|E|S|N] format Append +r if  lower  left  and
98              upper  right  map  coordinates are given instead of w/e/s/n. The
99              two shorthands -Rg and -Rd stand for global  domain  (0/360  and
100              -180/+180  in longitude respectively, with -90/+90 in latitude).
101              Alternatively for grid creation, give Rcodelon/lat/nx/ny,  where
102              code  is a 2-character combination of L, C, R (for left, center,
103              or right) and T, M, B for top, middle, or bottom. e.g.,  BL  for
104              lower  left.  This indicates which point on a rectangular region
105              the lon/lat coordinate refers to, and the grid dimensions nx and
106              ny with grid spacings via -I is used to create the corresponding
107              region.  Alternatively, specify the name  of  an  existing  grid
108              file  and  the -R settings (and grid spacing, if applicable) are
109              copied from the grid. Appending +uunit expects projected (Carte‐
110              sian)  coordinates  compatible  with  chosen -J and we inversely
111              project to determine actual rectangular geographic region.   For
112              perspective view (-p), optionally append /zmin/zmax.  In case of
113              perspective view (-p), a z-range (zmin, zmax) can be appended to
114              indicate  the  third  dimension. This needs to be done only when
115              using the -Jz option, not when using only the -p option. In  the
116              latter  case a perspective view of the plane is plotted, with no
117              third dimension.
118
119       -V[level] (more ...)
120              Select verbosity level [c].
121
122       -bi[ncols][t] (more ...)
123              Select native binary input. [Default is 2 input columns].
124
125       -bo[ncols][type] (more ...)
126              Select native binary output. [Default is same as input].
127
128       -d[i|o]nodata (more ...)
129              Replace input columns that equal nodata  with  NaN  and  do  the
130              reverse on output.
131
132       -e[~]"pattern" | -e[~]/regexp/[i] (more ...)
133              Only accept data records that match the given pattern.
134
135       -h[i|o][n][+c][+d][+rremark][+rtitle] (more ...)
136              Skip or produce header record(s).
137
138       -icols[+l][+sscale][+ooffset][,...] (more ...)
139              Select input columns and transformations (0 is first column).
140
141       -r (more ...)
142              Set pixel node registration [gridline].
143
144       -:[i|o] (more ...)
145              Swap 1st and 2nd column on input and/or output.
146
147       -^ or just -
148              Print  a  short  message  about  the syntax of the command, then
149              exits (NOTE: on Windows just use -).
150
151       -+ or just +
152              Print an extensive usage (help) message, including the  explana‐
153              tion  of  any  module-specific  option  (but  not the GMT common
154              options), then exits.
155
156       -? or no arguments
157              Print a complete usage (help) message, including the explanation
158              of all options, then exits.
159

ASCII FORMAT PRECISION

161       The ASCII output formats of numerical data are controlled by parameters
162       in your gmt.conf file. Longitude and latitude are  formatted  according
163       to   FORMAT_GEO_OUT,  absolute  time  is  under  the  control  of  FOR‐
164       MAT_DATE_OUT and FORMAT_CLOCK_OUT, whereas general floating point  val‐
165       ues are formatted according to FORMAT_FLOAT_OUT. Be aware that the for‐
166       mat in effect can lead to loss of precision in ASCII output, which  can
167       lead  to  various  problems  downstream.  If you find the output is not
168       written with enough precision, consider switching to binary output (-bo
169       if  available) or specify more decimals using the FORMAT_FLOAT_OUT set‐
170       ting.
171

GRID VALUES PRECISION

173       Regardless of the precision of the input data, GMT programs that create
174       grid  files  will  internally  hold  the grids in 4-byte floating point
175       arrays. This is done to conserve memory and furthermore most if not all
176       real  data  can be stored using 4-byte floating point values. Data with
177       higher precision (i.e., double precision values) will lose that  preci‐
178       sion  once  GMT  operates on the grid or writes out new grids. To limit
179       loss of precision when processing data you should always consider  nor‐
180       malizing the data prior to processing.
181

EXAMPLES

183       To  construct Voronoi polygons from the points in the file testdata.txt
184       and then calculate distances from the data to a global 1x1 degree grid,
185       use
186
187              gmt sphdistance testdata.txt -Rg -I1 -Gglobedist.nc
188
189       To generate the same grid in two steps using sphtriangulate separately,
190       try
191
192              gmt sphtriangulate testdata.txt -Qv > voronoi.txt
193              gmt sphdistance -Qvoronoi.txt -Rg -I1 -Gglobedist.nc
194

SEE ALSO

196       gmt, sphtriangulate, triangulate
197

REFERENCES

199       Renka, R, J., 1997, Algorithm 772: STRIPACK: Delaunay Triangulation and
200       Voronoi  Diagram on the Surface of a Sphere, AMC Trans. Math. Software,
201       23(3), 416-434.
202
204       2019, P. Wessel, W. H. F. Smith, R. Scharroo, J. Luis, and F. Wobbe
205
206
207
208
2095.4.5                            Feb 24, 2019                   SPHDISTANCE(1)
Impressum