GRDRASTER(1)

NAME
grdraster - extract subregion from a binary raster and write a grid file

SYNOPSIS
grdraster [ filenumber | "text pattern" ] -Rwest/east/south/north[r] [ -Ggrdfile ] [ -Ixinc[m|c][/yinc[m|c]] ] [ -Jparameters ] [ -V ] [ -bo[s|S|d|D[ncol]|c[var1/...]] ]

DESCRIPTION
grdraster reads a file called grdraster.info from the current working directory, the directories pointed to by the environment variables $GMT_DATADIR and $GMT_USERDIR, or in $GMT_SHAREDIR/dbase (in that order). The file grdraster.info defines binary arrays of data stored in scan-line format in data files. Each file is given a filenumber in the info file. grdraster figures out how to load the raster data into a grid file spanning a region defined by -R. By default the grid spacing equals the raster spacing. The -I option may be used to sub-sample the raster data. No filtering or interpolating is done, however; the x_inc and y_inc of the grid must be multiples of the increments of the raster file and grdraster simply takes every n'th point. The output of grdraster is either grid or pixel registered depending on the registration of the raster used. It is up to the GMT system person to maintain the grdraster.info file in accordance with the available rasters at each site. Raster data sets are not supplied with GMT but can be obtained by anonymous ftp and on CD-ROM (see README page in dbase directory). grdraster will list the available files if no arguments are given. Finally, grdraster will write xyz-triplets to stdout if no output gridfile name is given

filenumber
    If an integer matching one of the files listed in the grdraster.info file is given we will use that data set, else we will match the given text pattern with the data set description in order to determine the data set.

-R  west, east, south, and north specify the Region of interest, 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. If r is appended, you may also specify a map projection to define the shape of your region. The output region will be rounded off to the nearest whole grid-step in both dimensions.

OPTIONS

-G  Name of output grid file. If not set, the grid will be written as ASCII (or binary; see -bo xyz-triplets to stdout instead.

-I  x_inc [and optionally y_inc] is the grid spacing. Optionally, append a suffix modifier. Geographical (degrees) coordinates: Append m to indicate arc minutes or c to indicate arc seconds. If one of the units e, k, i, or n is appended instead, the increment is assumed to be given in meter, km, miles, or nautical miles, respectively, and will be converted to the equivalent degrees longitude at the middle latitude of the region (the conversion depends on ELLIPSOID). If /y_inc is given but set to 0 it will be reset equal to x_inc; otherwise it will be converted to degrees latitude. All coordinates: If = is appended then the corresponding max x (east) or y (north) may be slightly adjusted to fit exactly the given increment [by default the increment may be adjusted slightly to fit the given domain]. Finally, instead of giving an increment you may specify the number of nodes desired by appending + to the supplied integer argument; the increment is then recalculated from the number of nodes and the domain. The resulting increment value depends on whether you have selected a gridline-registered or pixel-registered grid; see Appendix B for details. Note: if -Rgrdfile is used then grid spacing has already been initialized; use -I to override the values.

-J  Selects the map projection. Scale is UNIT/degree, 1:xxxxx, or width in UNIT (upper case modifier). UNIT is cm, inch, or m, depending on the MEASURE_UNIT setting in .gmtdefaults4, but this can be overridden on the command line by appending c, i, or m to the scale/width value. When central meridian is optional, default is center of longitude range on -R option. Default standard parallel is the equator. For map height, max dimension, or min dimension, append h, +, or - to the width, respectively.
    More details can be found in the psbasemap man pages.

    CYLINDRICAL PROJECTIONS:

    -Jclon0/lat0/scale (Cassini)
    -Jcyl_stere/[lon0/[lat0/]]scale (Cylindrical Stereographic)
    -Jj[lon0/]scale (Miller)
    -Jm[lon0/[lat0/]]scale (Mercator)
    -Jmlon0/lat0/scale (Mercator - Give meridian and standard parallel)
    -Jo[a]lon0/lat0/azimuth/scale (Oblique Mercator - point and azimuth)
    -Jo[b]lon0/lat0/lon1/lat1/scale (Oblique Mercator - two points)
    -Joclon0/lat0/lonp/latp/scale (Oblique Mercator - point and pole)
    -Jq[lon0/[lat0/]]scale (Cylindrical Equidistant)
    -Jtlon0/[lat0/]scale (TM - Transverse Mercator)
    -Juzone/scale (UTM - Universal Transverse Mercator)
    -Jy[lon0/[lat0/]]scale (Cylindrical Equal-Area)

    CONIC PROJECTIONS:

    -Jblon0/lat0/lat1/lat2/scale (Albers)
    -Jdlon0/lat0/lat1/lat2/scale (Conic Equidistant)
    -Jllon0/lat0/lat1/lat2/scale (Lambert Conic Conformal)
    -Jpoly/[lon0/[lat0/]]scale ((American) Polyconic)

    AZIMUTHAL PROJECTIONS:

    -Jalon0/lat0[/horizon]/scale (Lambert Azimuthal Equal-Area)
    -Jelon0/lat0[/horizon]/scale (Azimuthal Equidistant)
    -Jflon0/lat0[/horizon]/scale (Gnomonic)
    -Jglon0/lat0[/horizon]/scale (Orthographic)
    -Jglon0/lat0/altitude/azimuth/tilt/twist/Width/Height/scale (General Perspective).
    -Jslon0/lat0[/horizon]/scale (General Stereographic)

    MISCELLANEOUS PROJECTIONS:

    -Jh[lon0/]scale (Hammer)
    -Ji[lon0/]scale (Sinusoidal)
    -Jkf[lon0/]scale (Eckert IV)
    -Jk[s][lon0/]scale (Eckert VI)
    -Jn[lon0/]scale (Robinson)
    -Jr[lon0/]scale (Winkel Tripel)
    -Jv[lon0/]scale (Van der Grinten)
    -Jw[lon0/]scale (Mollweide)

    NON-GEOGRAPHICAL PROJECTIONS:

    -Jp[a]scale[/origin][r|z] (Polar coordinates (theta,r))
    -Jxx-scale[d|l|ppow|t|T][/y-scale[d|l|ppow|t|T]] (Linear, log, and power scaling)

-V  Selects verbose mode, which will send progress reports to stderr [Default runs "silently"].

-bo Selects binary output. Append s for single precision [Default is d (double)]. Uppercase S or D will force byte-swapping. Optionally, append ncol, the number of desired columns in your binary output file. This option applies only if no -G option has been set.

EXAMPLES

To extract data from raster 1, taking one point every 30 minutes, in an area extended beyond 360 degrees to allow later filtering, run

grdraster 1 -R-4/364/-62/62 -I 30m -G data.grd

To obtain data for an oblique Mercator projection we need to extract more data that is actually used. This is necessary because the output of grdraster has edges defined by parallels and meridians, while the oblique map in general does not. Hence, to get all the data from the ETOPO2 data needed to make a contour map for the region defined by its lower left and upper right corners and the desired projection, use

grdraster ETOPO2 -R 160/20/220/30r -Joc 190/25.5/292/69/1 -G data.grd

To extract data from the 2 min Geoware relief blend and write it as binary double precision xyz-triplets to standard output:

grdraster "2 min Geoware" -R 20/25/-10/5 -bo >! triplets.b

SEE ALSO
gmtdefaults(1), GMT(1), grdsample(1), grdfilter(1)

REFERENCES
Wessel, P., and W. H. F. Smith, 2014, The Generic Mapping Tools (GMT) version 4.5.12 Technical Reference & Cookbook, SOEST/NOAA.
Wessel, P., and W. H. F. Smith, 1998, New, Improved Version of Generic Mapping Tools Released, EOS Trans., AGU, 79 (47), p. 579.
Wessel, P., and W. H. F. Smith, 1995, New Version of the Generic Mapping Tools Released, EOS Trans., AGU, 76 (33), p. 329.
Wessel, P., and W. H. F. Smith, 1995, New Version of the Generic Mapping Tools Released, http://www.agu.org/eos_elec/95154e.html, Copyright 1995 by the American Geophysical Union.
Wessel, P., and W. H. F. Smith, 1991, Free Software Helps Map and Display Data, EOS Trans., AGU, 72 (41), p. 441.