Execute GDAL raster programs from GMT


gmt grdgdal infile -Aprog[+mmethod+ccpt] -Goutfile [ -Fgd opts”] [ -M[+r+w]] [ -Rregion ] [ -V[level] ] [ -bibinary ] [ -dnodata ] [ -eregexp ] [ -ggaps ] [ -hi ] [ -iflags ] [ -qiflags ] [ -rreg ] [ --PAR=value ]

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


Wrapper module to run some of the GDAL programs (currently gdalinfo, gdaldem, gdal_grid, gdal_translate, gdal_rasterize, and gdalwarp) from within GMT. Given that GMT and GDAL syntaxes are very different, this module offers a minimal set of GMT style options but the bulk of them, which use the original GDAL syntax, are passed via a -Fgdal options”. So, users are requested to consult the GDAL programs documentation to learn how to use it.

When writing grids, an option is offered to write them either using the GMT or the GDAL machinery. Each one has its pros and cons. For example, saving with GMT allows the access by external libraries (e.g. Matlab, Julia, Python) but it requires to make a copy of the saving array. So saving with GDAL may be more efficient but looses the goodies provided by GMT (but gain its own).

Required Arguments


Name of an ASCII [or binary, see -bi] or an OGR file for programs taking table data, or a 2-D grid file for the other cases. File format for grids is detected automatically, but for ingesting OGR formats -M+r must be used.


Select which GDAL program to run (currently one of info, dem, grid, rasterize, translate or warp). When program is dem then please append +mmethod (pick one of hillshade, color-relief, slope, TRI, TPI or roughness) and, for color-relief, you also need to specify a colormap with +ccpt_name.


Output file name. outfile is the name of the output grid (or image) file. When saving images, the GDAL machinery is picked by default.

Optional Arguments

-Fgdal opts

List of GDAL options for the selected program in -A wrapped in double quotes.


Read and write files via GDAL. -M alone selects both reading and writing with GDAL. Option -M+r alone instructs the program to read with GDAL (and save with GMT). This option is needed when reading OGR vector data. -M+w indicates that the output will be saved with GDAL.

-Rxmin/xmax/ymin/ymax[+r][+uunit] (more …)

Specify the region of interest. Using the -R option will select a subsection of the grid. If this subsection exceeds the boundaries of the grid, only the common region will be output.

-V[level] (more …)

Select verbosity level [w].

-bi[ncols][t] (more …)

Select native binary format for primary input. [Default is 3]. This option only applies to xyz input via GMT.

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

-g[a]x|y|d|X|Y|D|[col]zgap[+n|p] (more …)

Determine data gaps and line breaks.

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

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

-icols[+l][+sscale][+ooffset][,][,t[word]] (more …)

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

-qi[~]rows[+ccol][+a|f|s] (more …)

Select input rows or data range(s) [all].

-r[g|p] (more …)

Set node registration [gridline].

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


To interpolate the x,y,z data at 0.05 increment in a VRT file using the nearest neighbor algorithm and saving the result as a netCDF:

gmt grdgdal lixo.vrt -Agrid -R0/10/0/10 -I0.05 -F"-a nearest" -M+r

Now the same as above but saving the grid with GDAL and using the x,y,z point file directly:

gmt grdgdal lixo.csv -Agrid -R0/10/0/10 -I0.05 -F"-a nearest" -M+w

See Also

gmt.conf, gmt