Quick Navigator

Search Site

Unix VPS
A - Starter
B - Basic
C - Preferred
D - Commercial
MPS - Dedicated
Previous VPSs
* Sign Up! *

Contact Us
Online Help
Domain Status
Man Pages

Virtual Servers

Topology Map

Server Agreement
Year 2038

USA Flag



Man Pages

Manual Reference Pages  -  GRDTRACK (1)


grdtrack - Sampling of a 2-D grid file along 1-D trackline (a sequence of x,y points)


Ascii Format Precision
Grid File Formats


grdtrack xyfile -Ggrdfile [ -H[i][nrec] ] [ -Lflag ] [ -Q[b|c|l|n][[/]threshold] ] [ -Rwest/east/south/north[r] ] [ -S ] [ -V ] [ -Z ] [ -:[i|o] ] [ -b[i|o][s|S|d|D[ncol]|c[var1/...]] ] [ -f[i|o]colinfo ] [ -m[i|o][flag] ]


grdtrack reads a grid file (or a Sandwell/Smith IMG file) and a table (from file or standard input) with (x,y) positions in the first two columns (more columns may be present). It interpolates the grid at the positions in the table and writes out the table with the interpolated values added as a new column. A bicubic [Default], bilinear, B-spline or nearest-neighbor (see -Q) interpolation is used, requiring boundary conditions at the limits of the region (see -L).
xyfile This is an ASCII (or binary, see -b) file where the first 2 columns hold the (x,y) positions where the user wants to sample the 2-D data set.
-G grdfile is a 2-D binary grid file with the function f(x,y). If the specified grid is in Sandwell/Smith Mercator format you must append a comma-separated list of arguments that includes a scale to multiply the data (usually 1 or 0.1), the mode which stand for the following: (0) Img files with no constraint code, returns data at all points, (1) Img file with constraints coded, return data at all points, (2) Img file with constraints coded, return data only at constrained points and NaN elsewhere, and (3) Img file with constraints coded, return 1 at constraints and 0 elsewhere, and optionally the max latitude in the IMG file [80.738]. (See GRID FILE FORMAT below.)


No space between the option flag and the associated arguments.
-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 Boundary condition flag may be x or y or xy indicating data is periodic in range of x or y or both set by -R, or flag may be g indicating geographical conditions (x and y are lon and lat). [Default uses "natural" conditions (second partial derivative normal to edge is zero) unless the grid is automatically recognised as periodic.]
-Q Quick mode, use bilinear rather than bicubic interpolation [Default]. Alternatively, select the interpolation mode by adding b for B-spline smoothing, c for bicubic interpolation, l for bilinear interpolation or n for nearest-neighbor value. Optionally, append threshold in the range [0,1]. This parameter controls how close to nodes with NaN values the interpolation will go. E.g., a threshold of 0.5 will interpolate about half way from a non-NaN to a NaN node, whereas 0.1 will go about 90% of the way, etc. [Default is 1, which means none of the (4 or 16) nearby nodes may be NaN]. -Q0 will just return the value of the nearest node instead of interpolating. This is the same as using -Qn.
-R xmin, xmax, ymin, and ymax specify the Region of interest. For geographic regions, these limits correspond to west, east, south, and north and you may specify them in decimal degrees or in [+-]dd:mm[][W|E|S|N] format. Append r if lower left and upper right map coordinates are given instead of w/e/s/n. The two shorthands -Rg and -Rd stand for global domain (0/360 and -180/+180 in longitude respectively, with -90/+90 in latitude). Alternatively, specify the name of an existing grid file and the -R settings (and grid spacing, if applicable) are copied from the grid. For calendar time coordinates you may either give (a) relative time (relative to the selected TIME_EPOCH and in the selected TIME_UNIT; append t to -JX|x), or (b) absolute time of the form [date]T[clock] (append T to -JX|x). At least one of date and clock must be present; the T is always required. The date string must be of the form [-]yyyy[-mm[-dd]] (Gregorian calendar) or yyyy[-Www[-d]] (ISO week calendar), while the clock string must be of the form hh:mm:ss[.xxx]. The use of delimiters and their type and positions must be exactly as indicated (however, input, output and plot formats are customizable; see gmtdefaults).
-S Suppress the output of interpolated points that result in NaN values.
-V Selects verbose mode, which will send progress reports to stderr [Default runs "silently"].
-Z Only write out the sampled z-values [Default writes all columns].
-: Toggles between (longitude,latitude) and (latitude,longitude) input/output. [Default is (longitude,latitude)].
-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 one more than input].
-f Special formatting of input and/or output columns (time or geographical data). Specify i or o to make this apply only to input or output [Default applies to both]. Give one or more columns (or column ranges) separated by commas. Append T (absolute calendar time), t (relative time in chosen TIME_UNIT since TIME_EPOCH), x (longitude), y (latitude), or f (floating point) to each column or column range item. Shorthand -f[i|o]g means -f[i|o]0x,1y (geographic coordinates).
-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.


GMT is able to recognize many of the commonly used grid file formats, as well as the precision, scale and offset of the values contained in the grid file. When GMT needs a little help with that, you can add the suffix =id[/scale/offset[/nan]], where id is a two-letter identifier of the grid type and precision, and scale and offset are optional scale factor and offset to be applied to all grid values, and nan is the value used to indicate missing data. See grdreformat(1) and Section 4.17 of the GMT Technical Reference and Cookbook for more information.

When reading a netCDF file that contains multiple grids, GMT will read, by default, the first 2-dimensional grid that can find in that file. To coax GMT into reading another multi-dimensional variable in the grid file, append ?varname to the file name, where varname is the name of the variable. Note that you may need to escape the special meaning of ? in your shell program by putting a backslash in front of it, or by placing the filename and suffix between quotes or double quotes. See grdreformat(1) and Section 4.18 of the GMT Technical Reference and Cookbook for more information, particularly on how to read splices of 3-, 4-, or 5-dimensional grids.


If an interpolation point is not on a node of the input grid, then a NaN at any node in the neighborhood surrounding the point will yield an interpolated NaN. Bicubic interpolation [default] yields continuous first derivatives but requires a neighborhood of 4 nodes by 4 nodes. Bilinear interpolation [-Q] uses only a 2 by 2 neighborhood, but yields only zeroth-order continuity. Use bicubic when smoothness is important. Use bilinear to minimize the propagation of NaNs, or lower threshold.


To sample the file hawaii_topo.grd along the SEASAT track track_4.xyg (An ASCII table containing longitude, latitude, and SEASAT-derived gravity, preceded by one header record):

grdtrack track_4.xyg -G hawaii_topo.grd -H > track_4.xygt

To sample the Sandwell/Smith IMG format file topo.8.2.img (2 minute predicted bathymetry on a Mercator grid) along the lon,lat coordinates given in the file cruise_track.xy, try

grdtrack cruise_track.xy -G topo.8.2.img,1,1 > obs_and_predicted.d


GMT(1), surface(1), sample1d(1)
Search for    or go to Top of page |  Section 1 |  Main Index

GMT 4.5.14 GRDTRACK (1) 1 Nov 2015

Powered by GSP Visit the GSP FreeBSD Man Page Interface.
Output converted with manServer 1.07.