blockmedian - Block average (x, y, z) data tables by L1 norm
] [ -E
] ] [
] ] [ -Q
] [ -V
] ] [
] ] [ -b
binary ] [
nodata ] [ -e
regexp ] [ -f
flags ] [ -h
flags ] [ -o
flags ] [ -r
No space is allowed between the option flag and the associated
reads arbitrarily located (x
triples [or optionally weighted quadruples (
)] from standard input [or table
and writes to standard output a median position and value for every non-empty
block in a grid region defined by the -R
Either blockmean, blockmedian
, or blockmode should be used as a
pre-processor before running surface to avoid aliasing short wavelengths.
These routines are also generally useful for decimating or averaging (
) data. You can modify the precision of the output
format by editing the FORMAT_FLOAT_OUT parameter in your gmt.conf file, or you
may choose binary input and/or output to avoid loss of precision.
- x_inc [and optionally y_inc] is the grid
spacing. Optionally, append a suffix modifier. Geographical (degrees)
coordinates: Append m to indicate arc minutes or s to
indicate arc seconds. If one of the units e, f, k,
M, n or u is appended instead, the increment is
assumed to be given in meter, foot, km, Mile, nautical mile or US survey
foot, respectively, and will be converted to the equivalent degrees
longitude at the middle latitude of the region (the conversion depends on
PROJ_ELLIPSOID). If y_inc is given but set to 0 it will be reset
equal to x_inc; otherwise it will be converted to degrees latitude.
All coordinates: If +e is appended then the corresponding
max x (east) or y (north) may be slightly
adjusted to fit exactly the given increment [by default the increment may
be adjusted slightly to fit the given domain]. Finally, instead of giving
an increment you may specify the number of nodes desired by
appending +n to the supplied integer argument; the increment is
then recalculated from the number of nodes and the domain. The resulting
increment value depends on whether you have selected a gridline-registered
or pixel-registered grid; see App-file-formats for details. Note: if
-R grdfile is used then the grid spacing has already been
initialized; use -I to override the values.
- Specify the region of interest.
- 3 [or 4, see -W] column ASCII data table] column
ASCII file(s) [or binary, see -bi] holding (
x,y,z[, w]) data values. [w] is an
optional weight for the data. If no file is specified, blockmedian
will read from standard input.
- Use the center of the block as the output location [Default
uses the median x and median y as location (but see -Q)].
- Provide Extended report which includes s (the L1
scale of the median), l, the lowest value, and h, the high
value for each block. Output order becomes
[Default outputs x,y,z[,w]. For
box-and-whisker calculation, use -Eb which will output
q25 and q75 are the 25% and 75% quantiles, respectively. See
-W for w output.
- Provide source id s or record number r
output, i.e., append the source id or record number associated with the
median value. If tied then report the record number of the higher of the
two values; append - to instead report the record number of the
lower value. Note that both -E[b] and
-Er[-] may be specified. For -Es we
expect input records of the form
x,y,z[,w],sid, where sid is an
unsigned integer source id.
- (Quicker) Finds median z and (x,y) at
that the median z [Default finds median x, median y
independent of z]. Also see -C.
- Sets the quantile of the distribution to be returned
[Default is 0.5 which returns the median z]. Here, 0 <
quantile < 1.
- -V[level] (more ...)
- Select verbosity level [c].
- Weighted modifier[s]. Unweighted input and output have 3
columns x,y,z; Weighted i/o has 4 columns
x,y,z,w. Weights can be used in input to
construct weighted median values for each block. Weight sums can be
reported in output for later combining several runs, etc. Use -W
for weighted i/o, -Wi for weighted input only, and -Wo for
weighted output only. [Default uses unweighted i/o]. If your weights are
actually uncertainties (one sigma) then append +s and we compute
weight = 1/sigma.
- -bi[ncols][t] (more ...)
- Select native binary input. [Default is 3 (or 4 if
-Wi is set)].
- -bo[ncols][type] (more ...)
- Select native binary output. [Default is 3 (or 4 if
-Wo is set)]. -E adds 3 additional columns.
- -d[i|o]nodata (more ...)
- Replace input columns that equal nodata with NaN and
do the reverse on output.
- -e[~]"pattern" |
-e[ ~]/regexp/[i] (more ...)
- Only accept data records that match the given pattern.
- -f[i|o]colinfo (more ...)
- Specify data types of input and/or output columns.
- Skip or produce header record(s).
- Select input columns and transformations (0 is first
- -ocols[,...] (more ...)
- Select output columns (0 is first column).
- -r (more ...)
- Set pixel node registration [gridline]. Each block is the
locus of points nearest the grid value location. Consider an example with
-R10/15/10/15 and -I1: With the -r option, 10 <= (
x,y) < 11 is one of 25 blocks; without it 9.5 <=
(x, y) < 10.5 is one of 36 blocks.
- -:[i|o] (more ...)
- Swap 1st and 2nd column on input and/or output.
- -^ or just -
- Print a short message about the syntax of the command, then
exits (NOTE: on Windows just use -).
- -+ or just +
- Print an extensive usage (help) message, including the
explanation of any module-specific option (but not the GMT common
options), then exits.
- -? or no arguments
- Print a complete usage (help) message, including the
explanation of all options, then exits.
The ASCII output formats of numerical data are controlled by parameters in your
gmt.conf file. Longitude and latitude are formatted according to
FORMAT_GEO_OUT, absolute time is under the control of FORMAT_DATE_OUT and
FORMAT_CLOCK_OUT, whereas general floating point values are formatted
according to FORMAT_FLOAT_OUT. Be aware that the format in effect can lead to
loss of precision in ASCII 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 FORMAT_FLOAT_OUT setting.
To find 5 by 5 minute block medians from the double precision binary data in
hawaii_b.xyg and output an ASCII table, run
gmt blockmedian hawaii_b.xyg -R198/208/18/25 -I5m -bi3d > hawaii_5x5.xyg
To compute the shape of a data distribution per bin via a box-and-whisker
diagram we need the 0%, 25%, 50%, 75%, and 100% quantiles. To do so on a
global 5 by 5 degree basis from the ASCII table depths.xyz and send output to
an ASCII table, run
gmt blockmedian depths.xyz -Rg -I5 -Eb -r > depths_5x5.txt
blockmean, blockmode, gmt, gmt.conf, greenspline, nearneighbor, surface,
2017, P. Wessel, W. H. F. Smith, R. Scharroo, J. Luis, and F. Wobbe