grdgdal — GMT 6.4.0 documentation

# grdgdal

Execute GDAL raster programs from GMT

## Synopsis

gmt grdgdal infile -A prog[+mmethod+ccpt] -G outfile [ -F“gd opts”] [ -M[+r[+w]]] [ -R region ] [ -V[level] ] [ -bi binary ] [ -d nodata[+ccol] ] [ -e regexp ] [ -g gaps ] [ -hi ] [ -i flags ] [ -qi flags ] [ -r reg ] [ --PAR=value ]

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

## Description

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 -F“gdal 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

infile

  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.

-Aprog[+mmethod+ccpt]

  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.

-Goutgrid[=ID][+ddivisor][+ninvalid][+ooffset|a][+sscale|a][:driver[dataType][+coptions]]

> Give the name of the output grid (or images) file. When saving images, the GDAL machinery is picked by default. Optionally, append =ID for writing a specific file format (See full description). The following modifiers are supported:

> > - +d - Divide data values by given divisor [Default is 1].

> > - +n - Replace data values matching invalid with a NaN.

> > - +o - Offset data values by the given offset, or append a for automatic range offset to preserve precision for integer grids [Default is 0].

> > - +s - Scale data values by the given scale, or append a for automatic scaling to preserve precision for integer grids [Default is 1].

> Note: Any offset is added before any scaling. +sa also sets +oa (unless overridden). To write specific formats via GDAL, use =gd and supply driver (and optionally dataType) and/or one or more concatenated GDAL -co options using +c. See the “Writing grids and images” cookbook section for more details.

## Optional Arguments

-F“gdal opts”

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

-M[+r[+w]]

  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]

  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. (See full description) (See cookbook information).

-V[level]

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

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

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

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

-gx|y|z|d|X|Y|Dgap[u][+a][+ccol][+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][+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).

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

  Select input rows or data limit(s) [default is all rows].

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

--PAR=value

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

## Examples

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 -Gjunk.nc -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 -Gjunk.nc -I0.05 -F"-a nearest" -M+w

## See Also

gmt.conf, gmt