1NEARNEIGHBOR(1) GMT NEARNEIGHBOR(1)
2
3
4
6 nearneighbor - "Grid table data using a ""Nearest neighbor"" algorithm"
7
9 nearneighbor [ table ] -Gout_grdfile
10 -Iincrement
11 -Nsectors[/min_sectors]
12 -Rregion
13 -Ssearch_radius[unit] [ -Eempty ] [ -V[level] ] [ -W ] [ -bibinary
14 ] [ -dinodata ] [ -eregexp ] [ -fflags ] [ -hheaders ] [ -iflags ] [
15 -nflags ] [ -r ] [ -:[i|o] ]
16
17 Note: No space is allowed between the option flag and the associated
18 arguments.
19
21 nearneighbor reads arbitrarily located (x,y,z[,w]) triples [quadru‐
22 plets] from standard input [or table] and uses a nearest neighbor algo‐
23 rithm to assign an average value to each node that have one or more
24 points within a radius centered on the node. The average value is com‐
25 puted as a weighted mean of the nearest point from each sector inside
26 the search radius. The weighting function used is w(r) = 1 / (1 + d ^
27 2), where d = 3 * r / search_radius and r is distance from the node.
28 This weight is modulated by the weights of the observation points [if
29 supplied].
30
32 -Gout_grdfile
33 Give the name of the output grid file.
34
35 -Ixinc[unit][+e|n][/yinc[unit][+e|n]]
36 x_inc [and optionally y_inc] is the grid spacing. Optionally,
37 append a suffix modifier. Geographical (degrees) coordinates:
38 Append m to indicate arc minutes or s to indicate arc seconds.
39 If one of the units e, f, k, M, n or u is appended instead, the
40 increment is assumed to be given in meter, foot, km, Mile, nau‐
41 tical mile or US survey foot, respectively, and will be con‐
42 verted to the equivalent degrees longitude at the middle lati‐
43 tude of the region (the conversion depends on PROJ_ELLIPSOID).
44 If y_inc is given but set to 0 it will be reset equal to x_inc;
45 otherwise it will be converted to degrees latitude. All coordi‐
46 nates: If +e is appended then the corresponding max x (east) or
47 y (north) may be slightly adjusted to fit exactly the given
48 increment [by default the increment may be adjusted slightly to
49 fit the given domain]. Finally, instead of giving an increment
50 you may specify the number of nodes desired by appending +n to
51 the supplied integer argument; the increment is then recalcu‐
52 lated from the number of nodes and the domain. The resulting
53 increment value depends on whether you have selected a grid‐
54 line-registered or pixel-registered grid; see App-file-formats
55 for details. Note: if -Rgrdfile is used then the grid spacing
56 has already been initialized; use -I to override the values.
57
58 -Nsectors[/min_sectors]
59 The circular area centered on each node is divided into sectors
60 sectors. Average values will only be computed if there is at
61 least one value inside each of at least min_sectors of the sec‐
62 tors for a given node. Nodes that fail this test are assigned
63 the value NaN (but see -E). If min_sectors is omitted it is set
64 to be at least 50% of sectors (i.e., rounded up to next inte‐
65 ger). [Default is a quadrant search with 100% coverage, i.e.,
66 sectors = min_sectors = 4]. Note that only the nearest value per
67 sector enters into the averaging; the more distant points are
68 ignored.
69
70 -Rxmin/xmax/ymin/ymax[+r][+uunit] (more ...)
71 Specify the region of interest.
72
73 -Ssearch_radius[unit]
74 Sets the search_radius that determines which data points are
75 considered close to a node. Append the distance unit (see
76 UNITS).
77
79 table 3 [or 4, see -W] column ASCII file(s) [or binary, see -bi] hold‐
80 ing (x,y,z[,w]) data values. If no file is specified, nearneigh‐
81 bor will read from standard input.
82
83 -Eempty
84 Set the value assigned to empty nodes [NaN].
85
86 -V[level] (more ...)
87 Select verbosity level [c].
88
89 -W Input data have a 4th column containing observation point
90 weights. These are multiplied with the geometrical weight fac‐
91 tor to determine the actual weights used in the calculations.
92
93 -bi[ncols][t] (more ...)
94 Select native binary input. [Default is 3 (or 4 if -W is set)
95 columns].
96
97 -dinodata (more ...)
98 Replace input columns that equal nodata with NaN.
99
100 -e[~]"pattern" | -e[~]/regexp/[i] (more ...)
101 Only accept data records that match the given pattern.
102
103 -f[i|o]colinfo (more ...)
104 Specify data types of input and/or output columns.
105
106 -h[i|o][n][+c][+d][+rremark][+rtitle] (more ...)
107 Skip or produce header record(s).
108
109 -icols[+l][+sscale][+ooffset][,...] (more ...)
110 Select input columns and transformations (0 is first column).
111
112 -n[b|c|l|n][+a][+bBC][+tthreshold]
113 Append +bBC to set any boundary conditions to be used, adding g
114 for geographic, p for periodic, or n for natural boundary condi‐
115 tions. For the latter two you may append x or y to specify just
116 one direction, otherwise both are assumed. [Default is geo‐
117 graphic if grid is geographic].
118
119 -r (more ...)
120 Set pixel node registration [gridline].
121
122 -:[i|o] (more ...)
123 Swap 1st and 2nd column on input and/or output.
124
125 -^ or just -
126 Print a short message about the syntax of the command, then
127 exits (NOTE: on Windows just use -).
128
129 -+ or just +
130 Print an extensive usage (help) message, including the explana‐
131 tion of any module-specific option (but not the GMT common
132 options), then exits.
133
134 -? or no arguments
135 Print a complete usage (help) message, including the explanation
136 of all options, then exits.
137
139 For map distance unit, append unit d for arc degree, m for arc minute,
140 and s for arc second, or e for meter [Default], f for foot, k for km, M
141 for statute mile, n for nautical mile, and u for US survey foot. By
142 default we compute such distances using a spherical approximation with
143 great circles. Prepend - to a distance (or the unit is no distance is
144 given) to perform "Flat Earth" calculations (quicker but less accurate)
145 or prepend + to perform exact geodesic calculations (slower but more
146 accurate).
147
149 Regardless of the precision of the input data, GMT programs that create
150 grid files will internally hold the grids in 4-byte floating point
151 arrays. This is done to conserve memory and furthermore most if not all
152 real data can be stored using 4-byte floating point values. Data with
153 higher precision (i.e., double precision values) will lose that preci‐
154 sion once GMT operates on the grid or writes out new grids. To limit
155 loss of precision when processing data you should always consider nor‐
156 malizing the data prior to processing.
157
159 To create a gridded data set from the file seaMARCII_bathy.lon_lat_z
160 using a 0.5 min grid, a 5 km search radius, using an octant search with
161 100% sector coverage, and set empty nodes to -9999:
162
163 gmt nearneighbor seaMARCII_bathy.lon_lat_z -R242/244/-22/-20 -I0.5m \
164 -E-9999 -Gbathymetry.nc -S5k -N8/8
165
166 To make a global grid file from the data in geoid.xyz using a 1 degree
167 grid, a 200 km search radius, spherical distances, using an quadrant
168 search, and set nodes to NaN only when fewer than two quadrants contain
169 at least one value:
170
171 gmt nearneighbor geoid.xyz -R0/360/-90/90 -I1 -Lg -Ggeoid.nc -S200k -N4
172
174 blockmean, blockmedian, blockmode, gmt, greenspline, sphtriangulate,
175 surface, triangulate
176
178 2019, P. Wessel, W. H. F. Smith, R. Scharroo, J. Luis, and F. Wobbe
179
180
181
182
1835.4.5 Feb 24, 2019 NEARNEIGHBOR(1)