1SPHDISTANCE(1)               Generic Mapping Tools              SPHDISTANCE(1)
2
3
4

NAME

6       sphdistance  - Calculate nearest distances from Voronoi construction of
7       spherical data
8

SYNOPSIS

10       sphdistance infiles -Ggrdfile [ -C ] [ -D ] [ -E ] [ -F ] [ -H[i][nrec]
11       ]  [ -Ixinc[unit][=|+][/yinc[unit][=|+]] ] [ -Lunit ] [ -Qvoronoi.d ] [
12       -Rwest/east/south/north[r]   ]   [    -V    ]    [    -:[i|o]    ]    [
13       -b[i|o][s|S|d|D[ncol]|c[var1/...]] ] [ -m[i|o][flag] ]
14

DESCRIPTION

16       sphdistance  reads  one  or  more  ASCII [or binary] files (or standard
17       input) containing lon, lat and performs  the  construction  of  Voronoi
18       polygons.   These  polygons are then processed to calculate the nearest
19       distance to each node of the lattice and written to the specified grid.
20       The  Voronoi algorithm used is STRIPACK.  As an option, you may provide
21       pre-calculated Voronoi polygon file in the format written by  sphtrian‐
22       gulate,  thus  bypassing  the memory- and time-consuming triangulariza‐
23       tion.
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
29       -G     Name of the output grid to hold the computed distances.
30

OPTIONS

32       -C     For  large  data set you can save some memory (at the expense of
33              more processing) by only storing one form  of  location  coordi‐
34              nates  (geographic  or Cartesian 3-D vectors) at any given time,
35              translating from one form to the other when  necessary  [Default
36              keeps both arrays in memory]. Not applicable with -Q.
37
38       -D     Used with -m to skip the last (repeated) input vertex at the end
39              of a closed segment if it equals the first point in the segment.
40              Requires -m [Default uses all points].
41
42       -E     Instead  of  computing  distances,  return the ID numbers of the
43              Voronoi polygons that each grid node is inside [Default computes
44              distances].
45
46       -F     Force  pixel  node  registration  [Default is gridline registra‐
47              tion].  (Node registrations are defined in GMT Cookbook Appendix
48              B on grid file formats.)
49
50       -H     Input file(s) has header record(s).  If used, the default number
51              of header records is N_HEADER_RECS.  Use -Hi if only input  data
52              should  have  header  records  [Default  will  write  out header
53              records if the input data have  them].  Blank  lines  and  lines
54              starting with # are always skipped.
55
56       -I     x_inc  [and  optionally  y_inc] is the grid spacing. Optionally,
57              append a suffix modifier.  Geographical  (degrees)  coordinates:
58              Append  m  to indicate arc minutes or c to indicate arc seconds.
59              If one of the units e, k, i,  or  n  is  appended  instead,  the
60              increment  is assumed to be given in meter, km, miles, or nauti‐
61              cal miles, respectively, and will be converted to the equivalent
62              degrees longitude at the middle latitude of the region (the con‐
63              version depends on ELLIPSOID).  If /y_inc is given but set to  0
64              it  will be reset equal to x_inc; otherwise it will be converted
65              to degrees latitude.  All coordinates: If = is appended then the
66              corresponding max x (east) or y (north) may be slightly adjusted
67              to fit exactly the given increment [by default the increment may
68              be adjusted slightly to fit the given domain].  Finally, instead
69              of giving an increment you  may  specify  the  number  of  nodes
70              desired  by  appending  +  to the supplied integer argument; the
71              increment is then recalculated from the number of nodes and  the
72              domain.   The  resulting  increment value depends on whether you
73              have selected a gridline-registered  or  pixel-registered  grid;
74              see  Appendix  B  for  details.  Note: if -Rgrdfile is used then
75              grid spacing has already been initialized; use  -I  to  override
76              the values.
77
78       -L     Specify the unit used for distance calculations.  Choose among e
79              (m), k (km), m  (mile),  n  (nautical  mile),  or  d  (spherical
80              degree).   A spherical approximation is used unless ELLIPSOID is
81              set to an actual ellipsoid.  -N Read the information  pertaining
82              to  each  Voronoi  polygon (the unique node lon, lat and polygon
83              area) from a separate file [Default  acquires  this  information
84              from the ASCII segment headers of the output file].  Required if
85              binary input via -Q is used.
86
87       -Q     Append the name of a file with pre-calculated  Voronoi  polygons
88              [Default  performs the Voronoi construction on input data].  For
89              binary data -bi you must specify the node information separately
90              (via -N).
91
92       -R     west, east, south, and north specify the Region of interest, and
93              you   may   specify   them   in   decimal    degrees    or    in
94              [+-]dd:mm[:ss.xxx][W|E|S|N]  format.  Append r if lower left and
95              upper right map coordinates are given instead of  w/e/s/n.   The
96              two  shorthands  -Rg  and -Rd stand for global domain (0/360 and
97              -180/+180 in longitude respectively, with -90/+90 in  latitude).
98              Alternatively, specify the name of an existing grid file and the
99              -R settings (and grid spacing, if applicable)  are  copied  from
100              the grid.
101
102       -V     Selects verbose mode, which will send progress reports to stderr
103              [Default runs "silently"].
104
105       -:     Toggles between  (longitude,latitude)  and  (latitude,longitude)
106              input and/or output.  [Default is (longitude,latitude)].  Append
107              i to select input only or o to  select  output  only.   [Default
108              affects both].
109
110       -bi    Selects binary input.  Append s for single precision [Default is
111              d  (double)].   Uppercase  S  or  D  will  force  byte-swapping.
112              Optionally,  append  ncol,  the number of columns in your binary
113              input file if it exceeds the columns needed by the program.   Or
114              append  c  if  the  input  file  is  netCDF.  Optionally, append
115              var1/var2/... to specify the variables to be read.  [Default  is
116              2 input columns].
117
118       -bo    Selects  binary  output.  Append s for single precision [Default
119              is d (double)].  Uppercase S  or  D  will  force  byte-swapping.
120              Optionally,  append  ncol, the number of desired columns in your
121              binary output file.  [Default is same as input].
122
123       -m     Multiple segment file(s).  Segments are separated by  a  special
124              record.   For  ASCII  files  the  first  character  must be flag
125              [Default is '>'].  For binary files all fields must be  NaN  and
126              -b must set the number of output columns explicitly.  By default
127              the -m setting applies to both input and output.   Use  -mi  and
128              -mo to give separate settings to input and output.
129

ASCII FORMAT PRECISION

131       The ASCII output formats of numerical data are controlled by parameters
132       in your .gmtdefaults4  file.   Longitude  and  latitude  are  formatted
133       according  to  OUTPUT_DEGREE_FORMAT, whereas other values are formatted
134       according to D_FORMAT.  Be aware that the format in effect can lead  to
135       loss  of  precision  in  the output, which can lead to various problems
136       downstream.  If you find the output is not written with  enough  preci‐
137       sion, consider switching to binary output (-bo if available) or specify
138       more decimals using the D_FORMAT setting.
139

GRID VALUES PRECISION

141       Regardless of the precision of the input data, GMT programs that create
142       grid  files  will  internally  hold  the grids in 4-byte floating point
143       arrays.  This is done to conserve memory and furthermore  most  if  not
144       all  real  data can be stored using 4-byte floating point values.  Data
145       with higher precision (i.e., double precision values)  will  lose  that
146       precision  once  GMT  operates on the grid or writes out new grids.  To
147       limit loss of precision when processing data you should always consider
148       normalizing the data prior to processing.
149

EXAMPLES

151       To  construct Voronoi polygons from the points in the file testdata.txt
152       and then calculate distances from the data to a global 1x1 degree grid,
153       use
154
155       sphdistance testdata.txt -Rg -I1 -Gglobedist.grd
156
157       To generate the same grid in two steps using sphtriangulate separately,
158       try
159
160       sphtriangulate testdata.txt -Qv > voronoi.d
161       sphdistance -Qvoronoi.d -Rg -I1 -Gglobedist.grd
162

SEE ALSO

164       GMT(1), sphinterpolate(1) sphtriangulate(1) triangulate(1)
165

REFERENCES

167       Renka, R, J., 1997, Algorithm 772: STRIPACK: Delaunay Triangulation and
168       Voronoi  Diagram on the Surface of a Sphere, AMC Trans. Math. Software,
169       23 (3), 416-434.
170
171
172
173GMT 4.5.6                         10 Mar 2011                   SPHDISTANCE(1)
Impressum