# GRDEDIT

NAME
SYNOPSIS
DESCRIPTION
OPTIONS
GRID FILE FORMATS
GEOGRAPHICAL AND TIME COORDINATES
EXAMPLES
SEE ALSO

## NAME

grdedit − Modifying the header or content of a 2-D grid file

## SYNOPSIS

grdedit grdfile [ −A ] [ −D xname/yname/zname/scale/offset/title/remark ] [ −E ] [ −N xyzfile ] [ −R west/east/south/north[r] ] [ −S ] [ −T ] [ −V ] [ −:[i|o] ] [ −bi[s|S|d|D[ncol]|c[var1/...]] ] [ −f[i|o]colinfo ]

## DESCRIPTION

grdedit reads the header information in a binary 2-D grid file and replaces the information with values provided on the command line [if any]. As an option, global, geographical grids (with 360 degrees longitude range) can be rotated in the east-west direction, and individual nodal values can be replaced from a table of x, y, z values. grdedit only operates on files containing a grdheader.
grdfile

Name of the 2-D grid file to modify. (See GRID FILE FORMATS below).

## OPTIONS

No space between the option flag and the associated arguments.

| −A |  | If necessary, adjust the file’s x_inc, y_inc to be compatible with its domain (or a new domain set with −R). Older grid files (i.e., created prior to GMT 3.1) often had excessive slop in x_inc, y_inc and an adjustment is necessary. Newer files are created correctly.
| −D |  | Give new values for xname, yname, zname, scale, offset, title, and remark. To leave some of the values untouched, specify = as the new value. Alternatively, to allow "/" to be part of one of the values, use any non-alphanumeric character (and not the equal sign) as separator by both starting and ending with it. For example: −D:xname:yname:zname:scale:offset:title:remark:
| −E |  | Transpose the grid and exchange the x and y information. Incompatible with the other options.
| −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.
| −N |  | Read the ASCII (or binary; see −bi) file xyzfile and replace the corresponding nodal values in the grid with these z values.
| −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[:ss.xxx][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). The new w/e/s/n values will replace those in the grid, and the x_inc, y_inc values are adjusted, if necessary.
| −S |  | For global, geographical grids only. Grid values will be shifted longitudinally according to the new borders given in −R.
| −T |  | Make necessary changes in the header to convert a gridline-registered grid to a pixel-registered grid, or vice-versa. Basically, gridline-registered grids will have their domain extended by half the x- and y-increments whereas pixel-registered grids will have their domain shrunk by the same amount.
| −V |  | Selects verbose mode, which will send progress reports to stderr [Default runs "silently"].
| −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 3 input columns].
| −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).

## GRID FILE FORMATS

By default GMT writes out grid as single precision floats in a COARDS-complaint netCDF file format. However, GMT is able to produce grid files in many other commonly used grid file formats and also facilitates so called "packing" of grids, writing out floating point data as 2- or 4-byte integers. To specify the precision, scale and offset, the user should 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. When reading grids, the format is generally automatically recognized. If not, the same suffix can be added to input grid file names. 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. The ?varname suffix can also be used for output grids to specify a variable name different from the default: "z". 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.

## GEOGRAPHICAL AND TIME COORDINATES

When the output grid type is netCDF, the coordinates will be labeled "longitude", "latitude", or "time" based on the attributes of the input data or grid (if any) or on the −f or −R options. For example, both −f0x −f1t and −R90w/90e/0t/3t will result in a longitude/time grid. When the x, y, or z coordinate is time, it will be stored in the grid as relative time since epoch as specified by TIME_UNIT and TIME_EPOCH in the .gmtdefaults file or on the command line. In addition, the unit attribute of the time variable will indicate both this unit and epoch.

## EXAMPLES

Let us assume the file data.grd covers the area 300/310/10/30. We want to change the boundaries from geodetic longitudes to geographic and put a new title in the header. We accomplish this by

grdedit data.grd −R-60/-50/10/30 −D=/=/=/=/=/"Gravity Anomalies"/=

The grid world.grd has the limits 0/360/-72/72. To shift the data so that the limits would be -180/180/-72/72, use

grdedit world.grd −R-180/180/-72/72 −S

The file junk.grd was created prior to GMT 3.1 with incompatible −R and −I arguments. To reset the x- and y-increments we run

grdedit junk.grd −A

The file junk.grd was created prior to GMT 4.1.3 and does not contain the required information to indicate that the grid is geographic. To add this information, run

grdedit junk.grd −fg

## SEE ALSO

GMT(1), grd2xyz(1), xyz2grd(1)