Calculate grid volume and area constrained by a contour


gmt grdvolume grdfile [ -Ccval or -Clow/high/delta or -Crlow/high or -Crcval] [ -D ] [ -Lbase ] [ -Rregion ] [ -S[unit] ] [ -T[c|h] ] [ -V[level] ] [ -Zfact[/shift] ] [ -fflags ] [ -oflags ] [ --PAR=value ]

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


grdvolume reads a 2-D grid file and calculates the volume contained below the surface and above the plane specified by the given contour (or zero if not given) and reports the contour, area, volume, and maximum mean height (volume/area). Alternatively, specify a range of contours to be tried and grdvolume will determine the volume and area inside the contour for all contour values. Using -T, the contour that produced the maximum mean height (or maximum curvature of heights vs contour value) is reported as well. This feature may be used with grdfilter in designing an Optimal Robust Separator [Wessel, 1998].

Required Arguments


The name of the input 2-D binary grid file. (See Grid File Formats).

Optional Arguments

-Ccval or -Clow/high/delta or -Crlow/high or -Crcval

find area, volume and mean height (volume/area) inside and above the cval contour. Alternatively, search using all contours from low to high in steps of delta. [Default returns area, volume and mean height of the entire grid]. The area is measured in the plane of the contour. The Cr form on the other hand computes the volume below the grid surface and above the planes defined by low and high, or below cval and grid’s minimum. Note that this is an outside volume whilst the other forms compute an inside (below the surface) area volume. Use this form to compute for example the volume of water between two contours. Note: If no -C is given then there is no contour and we return the entire grid area, volume and the mean height; cval will be reported as 0 but we are not tracing a zero-contour (which we do if -C0 is given).


Requires -Clow/high/delta and will compute the area and volume of each horizontal slice as defined by the contours. The reported contour and area values refer to the base of the slice, and the height is set to delta (since that is the thickness of all slices).


Also add in the volume from the level of the contour down to base [Default base is contour].


For geographical grids, append a unit from e|f|k|M|n|u [Default is meter (e)].


Determine the single contour that maximized the average height (= volume/area). Select -Tc to use the maximum curvature of heights versus contour value rather than the contour with the maximum height to pick the best contour value (requires -C).


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


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


Optionally subtract shift before scaling data by fact. [Default is no scaling]. (Numbers in -C, -L refer to values after this scaling has occurred).

-f[i|o]colinfo (more …)

Specify data types of input and/or output columns.

-ocols[,…][,t[word]] (more …)

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

-^ 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.


Note: Below are some examples of valid syntax for this module. The examples that use remote files (file names starting with @) can be cut and pasted into your terminal for testing. Other commands requiring input files are just dummy examples of the types of uses that are common but cannot be run verbatim as written.

To determine area (in km^2), volume (in km^3), and mean height (in km) of all land areas (above zero contour) in the Hawaiian Islands from the remote grid @earth_relief_05m (height in m), use:

gmt grdvolume @earth_relief_05m -R190/210/15/25 -C0 -Sk -Z0.001

To find the volume below the surface and above the contour z = 250 m in meters, use

gmt grdvolume -Se -C250

To search for the contour, ranging from 100 to 300 in steps of 10, that maximizes the ratio of volume to surface area for the file, use

gmt grdvolume -C0/300/10 -Th > results.d

To see the areas and volumes for all the contours in the previous example, use

gmt grdvolume -C100/300/10 > results.d

To find the volume of water in a lake with its free surface at 0 and max depth of 300 meters, use

gmt grdvolume -Cr-300/0

Volume integration

The surface will be approximated using a bilinear expression for the z-value inside each grid box defined by four grid nodes: \(z(x,y) = z_0 + z_x^{'}x + z_y^{'}y + z_{xy}^{''}xy\), where the first term is the grid value at the lower left corner of the cell (where our relative coordinates x = y = 0). The primed z-values are derivatives in x, y, and both directions, respectively. We analytically integrate this expression within each box, allowing for straight line contour intersections to go through a box and affect the integration domain and limits.


  1. The output of grdvolume is one or more records (one per contour if -C is set to search multiple contours) containing contour area volume volume/area. These records are written to standard output.

  2. For geographical grids we convert degrees to “Flat Earth” distances in meter. You can use -S to select another distance unit. The area is then reported in this unit squared while the volume is reported in unit^2 * z_unit quantities.

  3. grdvolume distinguishes between gridline and pixel-registered grids. In both cases the area and volume are computed up to the grid boundaries. That means that in the first case the grid cells on the boundary only contribute half their area (and volume), whereas in the second case all grid cells are fully used. The exception is when the -C flag is used: since contours do not extend beyond the outermost grid point, both grid types are treated the same. That means the outer rim in pixel oriented grids is ignored when using the -C flag.


Wessel, P., 1998, An empirical method for optimal robust regional-residual separation of geophysical data, Math. Geol., 30(4), 391-408.