image

Plot raster or EPS images

Synopsis

gmt image imagefile [ -B[p|s]parameters ] [ -Drefpoint ] [ -Fbox ] [ -G[color][+b|f|t] ] [ -I ] [ -Jparameters ] [ -Jz|Zparameters ] [ -M ] [ -Rwest/east/south/north[/zmin/zmax][+r][+uunit] ] [ -U[stamp] ] [ -V[level] ] [ -X[a|c|f|r][xshift] ] [ -Y[a|c|f|r][yshift] ] [ -pflags ] [ -ttransp ] [ --PAR=value ]

Description

image reads an Encapsulated PostScript file or a raster image file and plots it on a map. The image can be scaled arbitrarily, and 1-bit raster images can be (1) inverted, i.e., black pixels (on) becomes white (off) and vice versa, or (2) colorized, by assigning different foreground and background colors, and (3) made transparent where one of back- or foreground is painted only. As an option, the user may choose to convert colored raster images to grayscale using TV’s YIQ-transformation. For raster files, the user can select which color to be made transparent. The user may also choose to replicate the image which, when preceded by appropriate clip paths, may allow larger custom-designed fill patterns to be implemented (the -Gp mechanism offered in most GMT programs is limited to rasters smaller than 146 by 146).

Required Arguments

imagefile

This must be an Encapsulated PostScript (EPS) file or a raster image. An EPS file must contain an appropriate BoundingBox. A raster file can have a depth of 1, 8, 24, or 32 bits and is read via GDAL. Note: If GDAL was not configured during GMT installation then only EPS files are supported.

Optional Arguments

-B[p|s]parameters

Set map boundary frame and axes attributes. (See full description) (See cookbook information).

-D[g|j|J|n|x]refpoint+rdpi+w[-]width[/height][+jjustify][+nnx[/ny] ][+odx[/dy]]

Sets reference point on the map for the image using one of four coordinate systems:

  1. Append glon/lat for map coordinates. Requires both -R and -J to be set.

  2. Append jcode or Jcode for setting the refpoint via a 2-char justification code that refers to the (invisible) projected map bounding box. Requires both -R and -J to be set.

  3. Append nxn/yn for normalized bounding box coordinates (0-1). Requires both -R and -J to be set.

  4. Append xx/y for plot coordinates (append cm, inch, or ppoint).

By default, the anchor point on the scale is assumed to be the bottom left corner (BL), but this can be changed by appending +j followed by a 2-char justification code justify (see text). Note: If -Dj is used then justify defaults to the same as refpoint, if -DJ is used then justify defaults to the mirror opposite of refpoint. Specify image size in one of two ways: Use +rdpi to set the dpi of the image in dots per inch, or use +w[-]width[/height] to set the width (and height) of the image in plot coordinates (inches, cm, etc.). If height is not given, the original aspect ratio of the image is maintained. If width is negative we use the absolute value and interpolate image to the device resolution using the PostScript image operator. Optionally, use +nnx[/ny] to replicate the image nx times horizontally and ny times vertically. If ny is omitted, it will be identical to nx [Default is 1/1].

-F[+cclearances][+gfill][+i[[gap/]pen]][+p[pen]][+r[radius]][+s[[dx/dy/][shade]]]

Without further options, draws a rectangular border around the image using MAP_FRAME_PEN. The following modifiers can be appended to -F, with additional explanation and examples provided in the The background panel cookbook section:

  • +cclearance where clearance is either gap, xgap/ygap, or lgap/rgap/bgap/tgap and gap gives a uniform clearance, xgap/ygap gives separate clearances in the x- and y- directions, and lgap/rgap/bgap/tgap gives individual clearances between the map embellishment and the border for each side.

  • +gfill to fill the box with a color specified by fill [default is no fill].

  • +i[[gap/]pen] to draw a secondary, inner border as well. Optionally, specify the gap between the inner and outer border and the pen for the inner border [default is a uniform gap between borders of 2p and the MAP_DEFAULT_PEN].

  • +ppen to specify different pen attributes.

  • +r[radius] to draw rounded rectangular borders instead with a corner radius set by radius (append units) [defaults is 6p].

  • +s[[dx/dy/][shade]] to draw an offset background shaded region. Here, dx/dy indicates the shift relative to the foreground frame [default is 4p/-4p] and shade sets the fill style to use for shading [default is gray50].

-G[color][+b|f|t]

Change certain pixel values to another color or make them transparent. For 1-bit images you can specify an alternate color for the background (+b) or the foreground (+f) pixels, or give no color to make those pixels transparent. Alternatively, for color images you can select a single color that should be made transparent instead (+t).

-I

Invert 1-bit image before plotting. This is what is done when you use -GP to invert patterns in other GMT plotting programs. Ignored if used with color images.

-Jparameters

Specify the projection. (Used only with -p)

-M

Convert color image to monochrome grayshades using the (television) YIQ-transformation.

-Rxmin/xmax/ymin/ymax[+r][+uunit]

Specify the region of interest. (Used only with -p) (See full description) (See cookbook information).

For perspective view -p, optionally append /zmin/zmax. (more …)

-U[label|+c][+jjust][+odx[/dy]]

Draw GMT time stamp logo on plot. (See full description) (See cookbook information).

-V[level]

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

-X[a|c|f|r][xshift]

Shift plot origin. (See full description) (See cookbook information).

-Y[a|c|f|r][yshift]

Shift plot origin. (See full description) (See cookbook information).

-p[x|y|z]azim[/elev[/zlevel]][+wlon0/lat0[/z0]][+vx0/y0] (more …)

Select perspective view. (Requires -R and -J for proper functioning).

-ttransp[/transp2] (more …)

Set transparency level(s) in percent.

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

Notes

The -G and -I options are for raster images only. They have no effect when placing Encapsulated PostScript files.

Examples

Note: Since many GMT plot examples are very short (i.e., one module call between the gmt begin and gmt end commands), we will often present them using the quick modern mode GMT Modern Mode One-line Commands syntax, which simplifies such short scripts.

To plot the remote image needle.jpg, scaling it be 7 cm wide (height is scaled accordingly), use:

gmt image @needle.jpg -Dx0/0+w7c -pdf plot

To plot the same file but reversing the bands, use:

gmt image @needle.jpg+b2,1,0 -Dx0/0+w7c -pdf plot

To only plot its red band as gray shade, use:

gmt image @needle.jpg+b0 -Dx0/0+w7c -pdf plot

To include an Encapsulated PostScript file gallo.eps with its upper right corner 2 inch to the right and 1 inch up from the current location, and have its width scaled to 3 inches, while keeping the aspect ratio, use:

gmt image @gallo.eps -Dx2i/1i+jTR+w3i -pdf image

To replicate the 1-bit remote raster image vader1.png, colorize it (dark gray background and yellow foreground), and setting each of 6 by 12 tiles to be 2.5 cm wide, use:

gmt image @vader1.png -Gdarkgray+b -Gyellow+f -Dx0/0+w2.5c+n6/12 -pdf image