pygmt.Figure.grdimage

Figure.grdimage(grid, **kwargs)

Project and plot grids or images.

Reads one 2-D grid file and produces a gray-shaded (or colored) map by plotting rectangles centered on each grid node and assigning them a gray-shade (or color) based on the z-value. Alternatively, grdimage reads three 2-D grid files with the red, green, and blue components directly (all must be in the 0-255 range). Optionally, illumination may be added by providing a file with intensities in the (-1,+1) range or instructions to derive intensities from the input data grid. Values outside this range will be clipped. Such intensity files can be created from the grid using grdgradient and, optionally, modified by grdmath or grdhisteq. A third alternative is available when GMT is build with GDAL support. Pass img which can be an image file (geo-referenced or not). In this case the images can optionally be illuminated with the file provided via the shading option. Here, if image has no coordinates then those of the intensity file will be used.

When using map projections, the grid is first resampled on a new rectangular grid with the same dimensions. Higher resolution images can be obtained by using the dpi option. To obtain the resampled value (and hence shade or color) of each map pixel, its location is inversely projected back onto the input grid after which a value is interpolated between the surrounding input grid values. By default bi-cubic interpolation is used. Aliasing is avoided by also forward projecting the input grid nodes. If two or more nodes are projected onto the same pixel, their average will dominate in the calculation of the pixel value. Interpolation and aliasing is controlled with the interpolation option.

The region option can be used to select a map region larger or smaller than that implied by the extent of the grid.

Full option list at https://docs.generic-mapping-tools.org/latest/grdimage.html

Aliases:

  • B = frame

  • C = cmap

  • E = dpi

  • I = shading

  • J = projection

  • M = monochrome

  • N = noclip

  • Q = nan_alpha

  • R = region

  • U = timestamp

  • V = verbose

  • n = interpolation

  • t = transparency

Parameters
  • grid (str or xarray.DataArray) – The file name of the input grid or the grid loaded as a DataArray.

  • frame (str or list) – Set map boundary frame and axes attributes.

  • cmap (str) – File name of a CPT file or C='color1,color2[,color3,...]' to build a linear continuous CPT from those colors automatically.

  • dpi (int) – [i|dpi]. Sets the resolution of the projected grid that will be created if a map projection other than Linear or Mercator was selected [100]. By default, the projected grid will be of the same size (rows and columns) as the input file. Specify i to use the PostScript image operator to interpolate the image at the device resolution.

  • projection (str) – Required if this is the first plot command. Select map projection.

  • monochrome (bool) – Force conversion to monochrome image using the (television) YIQ transformation. Cannot be used with nan_alpha.

  • noclip (bool) – Do not clip the image at the map boundary (only relevant for non-rectangular maps).

  • nan_alpha (bool) – Make grid nodes with z = NaN transparent, using the color-masking feature in PostScript Level 3 (the PS device must support PS Level 3).

  • region (str or list) – Required if this is the first plot command. 'xmin/xmax/ymin/ymax[+r][+uunit]'. Specify the region of interest.

  • verbose (str) –

    Select verbosity level [Default is w], which modulates the messages written to stderr. Choose among 7 levels of verbosity:

    • q - Quiet, not even fatal error messages are produced

    • e - Error messages only

    • w - Warnings [Default]

    • t - Timings (report runtimes for time-intensive algorthms);

    • i - Informational messages (same as “verbose=True”)

    • c - Compatibility warnings

    • d - Debugging messages

  • interpolation (str) –

    [b|c|l|n][+a][+bBC][+c][+tthreshold] Select interpolation mode for grids. You can select the type of spline used:

    • ’b’ for B-spline

    • ’c’ for bicubic [Default]

    • ’l’ for bilinear

    • ’n’ for nearest-neighbor

  • transparency (float) – Set transparency level, in [0-100] percent range. Default is 0, i.e., opaque. Only visible when PDF or raster format output is selected. Only the PNG format selection adds a transparency layer in the image (for further processing).