Compute geopotential anomalies over 3-D bodies by the method of Talwani


gmt talwani3d [ table ] [ -A ] [ -Ddensity ] ] [ -Ff|n[lat]|v ] [ -Goutfile ] [ -Iincrement ] [ -M[h][v] ] [ -Ntrackfile ] [ -Rregion ] [ -Zlevel|obsgrid ] [ -V[level] ] [ -bobinary ] [ -dnodata[+ccol] ] [ -eregexp ] [ -fflags ] [ -iflags ] [ -oflags ] [ -rreg ] [ -x[[-]n] ] [ --PAR=value ]

Note: No space is allowed between the option flag and the associated arguments.


talwani3d will read the multi-segment table from file (or standard input). This file contains horizontal contours of a 3-D body at different z-levels, with one contour per segment. Each segment header must contain the parameters zlevel density, which states the z level of the contour and the density of this slice (optionally, individual slice densities may be overridden by a fixed density contrast given via -D). We can compute anomalies on an equidistant grid (by specifying a new grid with -R and -I or provide an observation grid with desired elevations) or at arbitrary output points specified via -N. Choose between free-air anomalies, vertical gravity gradient anomalies, or geoid anomalies. Options are available to control axes units and direction. For theory, see Kim and Wessel [2016] and Talwani and Ewing [1960].

Required Arguments


The file describing the horizontal contours of the bodies. Contours will be automatically closed if not already closed, and repeated vertices will be eliminated. The segment header for each slice will be examined for the pair zlevel density, i.e., the depth level of the slice and a density contrast in \(\mbox{kg/m}^3\) or \(\mbox{g/cm}^3\); see -D for overriding this value.


Set the grid spacing as x_inc [and optionally y_inc].

Geographical (degrees) coordinates: Optionally, append an increment unit. Choose among:

  • d - Indicate arc degrees

  • m - Indicate arc minutes

  • s - Indicate arc seconds

If one of e (meter), f (foot), k (km), M (mile), n (nautical mile) or u (US survey foot), the the increment 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 not given or given but set to 0 it will be reset equal to x_inc; otherwise it will be converted to degrees latitude.

All coordinates: The following modifiers are supported:

  • +e - Slightly adjust the max x (east) or y (north) to fit exactly the given increment if needed [Default is to slightly adjust the increment to fit the given domain].

  • +n - Define the number of nodes rather than the increment, in which case the increment is recalculated from the number of nodes, the registration (see GMT File Formats), and the domain. Note: If -Rgrdfile is used then the grid spacing and the registration have already been initialized; use -I and -R to override these values.


Specify the region of interest. (See full description) (See cookbook information).

Optional Arguments


The z-axis should be positive upwards [Default is down].


Sets a fixed density contrast that overrides any individual slice settings in the model file, in \(\mbox{kg/m}^3\) or \(\mbox{g/cm}^3\).


Specify desired gravitational field component. Choose between f (free-air anomaly) [Default], n (geoid; optionally append average latitude for normal gravity reference value [Default is mid-grid (or mid-profile if -N)]) or v (vertical gravity gradient).


Specify the name of the output data (for grids, see Grid File Formats). Required when an equidistant grid is implied for output. If -N is used then output is written to standard output unless -G specifies an output file.


Sets distance units used. Append h to indicate that both horizontal distances are in km [m], and append z to indicate vertical distances are in km [m].


Specifies individual (x, y[, z]) locations where we wish to compute the predicted value. When this option is used there are no grids and the output data records are written to standard output (see -bo for binary output). If trackfile has 3 columns we take the z value as our observation level; this level may be overridden via -Z.


Select verbosity level [w]. (See full description) (See cookbook information).


Set observation level, either as a constant or variable by giving the name of a grid with observation levels. If the latter is used then this grid determines the output grid region as well [0].

-borecord[+b|l] (more …)

Select native binary format for table output. [Default is 2 output columns].

-d[i|o][+ccol]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.


Geographic grids (i.e., dimensions of longitude, latitude) will be converted to km via a “Flat Earth” approximation using the current ellipsoidal parameters.

-h[i|o][n][+c][+d][+msegheader][+rremark][+ttitle] (more …)

Skip or produce header record(s). Not used with binary data.

-icols[+l][+ddivisor][+sscale|d|k][+ooffset][,][,t[word]] (more …)

Select input columns and transformations (0 is first column, t is trailing text, append word to read one word only).

-ocols[+l][+ddivisor][+sscale|d|k][+ooffset][,][,t[word]] (more …)

Select output columns and transformations (0 is first column, t is trailing text, append word to write one word only).

-r[g|p] (more …)

Set node registration [gridline].

-x[[-]n] (more …)

Limit number of cores used in multi-threaded algorithms (OpenMP required).

-:[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 exit (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 exit.

-? or no arguments

Print a complete usage (help) message, including the explanation of all options, then exit.


Temporarily override a GMT default setting; repeatable. See gmt.conf for parameters.


For map distance unit, append unit d for arc degree, m for arc minute, and s for arc second, or e for meter [Default unless stated otherwise], f for foot, k for km, M for statute mile, n for nautical mile, and u for US survey foot. By default we compute such distances using a spherical approximation with great circles (-jg) using the authalic radius (see PROJ_MEAN_RADIUS). You can use -jf to perform “Flat Earth” calculations (quicker but less accurate) or -je to perform exact geodesic calculations (slower but more accurate; see PROJ_GEODESIC for method used).


To compute the free-air anomalies on a grid over a 3-D body that has been contoured and saved to body3d.txt, using 1700 \(\mbox{kg/m}^3\) as the fixed density contrast, with horizontal distances in km and vertical distances in meters, try

gmt talwani3d -R-200/200/-200/200 -I2 -Mh -G3dgrav.nc body3d.txt -D1700 -Ff

To obtain the vertical gravity gradient anomaly along the track in crossing.txt for the same model, try

gmt talwani3d -Ncrossing.txt -Mh body3d.txt -D1700 -Fv > vgg_crossing.txt

Finally, the geoid anomaly along the same track in crossing.txt for the same model (at 30S) is written to n_crossing.txt by

gmt talwani3d -Ncrossing.txt -Mh body3d.txt -D1700 -Fn-30 -Gn_crossing.txt


Kim, S.-S., and P. Wessel, 2016, New analytic solutions for modeling vertical gravity gradient anomalies, Geochem. Geophys. Geosyst., 17, https://doi.org/10.1002/2016GC006263.

Talwani, M., and M. Ewing, 1960, Rapid computation of gravitational attraction of three-dimensional bodies of arbitrary shape, Geophysics, 25, 203-225.

See Also

gmt.conf, gmt, grdmath, gravfft, gmtgravmag3d, grdgravmag3d, talwani2d