@@ -318,24 +318,59 @@ def grdcontour(self, grid, **kwargs):
318
318
319
319
@fmt_docstring
320
320
@use_alias (
321
- R = "region" ,
322
- J = "projection" ,
323
- W = "pen" ,
321
+ A = "img_out" ,
324
322
B = "frame" ,
325
- I = "shading" ,
326
323
C = "cmap" ,
324
+ D = "img_in" ,
325
+ E = "dpi" ,
326
+ G = "bit_color" ,
327
+ I = "shading" ,
328
+ J = "projection" ,
329
+ M = "monochrome" ,
330
+ N = "no_clip" ,
331
+ Q = "nan_transparent" ,
332
+ R = "region" ,
333
+ U = "timestamp" ,
334
+ V = "verbose" ,
327
335
X = "xshift" ,
328
336
Y = "yshift" ,
337
+ n = "interpolation" ,
329
338
p = "perspective" ,
330
339
t = "transparency" ,
331
340
x = "cores" ,
332
341
)
333
342
@kwargs_to_strings (R = "sequence" , p = "sequence" )
334
343
def grdimage (self , grid , ** kwargs ):
335
344
"""
336
- Project grids or images and plot them on maps.
337
-
338
- Takes a grid file name or an xarray.DataArray object as input.
345
+ Project and plot grids or images.
346
+
347
+ Reads a 2-D grid file and produces a gray-shaded (or colored) map by
348
+ building a rectangular image and assigning pixels a gray-shade (or
349
+ color) based on the z-value and the CPT file. Optionally, illumination
350
+ may be added by providing a file with intensities in the (-1,+1) range
351
+ or instructions to derive intensities from the input data grid. Values
352
+ outside this range will be clipped. Such intensity files can be created
353
+ from the grid using `grdgradient` and, optionally, modified by
354
+ `grdmath` or `grdhisteq`. If GMT is built with GDAL support, *grid* can
355
+ be an image file (geo-referenced or not). In this case the image can
356
+ optionally be illuminated with the file provided via the *shading*
357
+ option. Here, if image has no coordinates then those of the intensity
358
+ file will be used.
359
+
360
+ When using map projections, the grid is first resampled on a new
361
+ rectangular grid with the same dimensions. Higher resolution images can
362
+ be obtained by using the *dpi* option. To obtain the resampled value
363
+ (and hence shade or color) of each map pixel, its location is inversely
364
+ projected back onto the input grid after which a value is interpolated
365
+ between the surrounding input grid values. By default bi-cubic
366
+ interpolation is used. Aliasing is avoided by also forward projecting
367
+ the input grid nodes. If two or more nodes are projected onto the same
368
+ pixel, their average will dominate in the calculation of the pixel
369
+ value. Interpolation and aliasing is controlled with the
370
+ *interpolation* option.
371
+
372
+ The *region* option can be used to select a map region larger or
373
+ smaller than that implied by the extent of the grid.
339
374
340
375
Full option list at :gmt-docs:`grdimage.html`
341
376
@@ -344,8 +379,82 @@ def grdimage(self, grid, **kwargs):
344
379
Parameters
345
380
----------
346
381
grid : str or xarray.DataArray
347
- The file name of the input grid or the grid loaded as a DataArray.
382
+ The file name or a DataArray containing the input 2-D gridded data
383
+ set or image to be plotted (See GRID FILE FORMATS at
384
+ :gmt-docs:`grdimage.html#grid-file-formats`).
385
+ img_out : str
386
+ ``out_img[=driver]``.
387
+ Save an image in a raster format instead of PostScript. Use
388
+ extension .ppm for a Portable Pixel Map format which is the only
389
+ raster format GMT can natively write. For GMT installations
390
+ configured with GDAL support there are more choices: Append
391
+ *out_img* to select the image file name and extension. If the
392
+ extension is one of .bmp, .gif, .jpg, .png, or .tif then no driver
393
+ information is required. For other output formats you must append
394
+ the required GDAL driver. The *driver* is the driver code name used
395
+ by GDAL; see your GDAL installation's documentation for available
396
+ drivers. Append a **+c**\\ *options* string where options is a list
397
+ of one or more concatenated number of GDAL **-co** options. For
398
+ example, to write a GeoPDF with the TerraGo format use
399
+ ``=PDF+cGEO_ENCODING=OGC_BP``. Notes: (1) If a tiff file (.tif) is
400
+ selected then we will write a GeoTiff image if the GMT projection
401
+ syntax translates into a PROJ syntax, otherwise a plain tiff file
402
+ is produced. (2) Any vector elements will be lost.
403
+ {B}
404
+ {CPT}
405
+ img_in : str
406
+ ``[r]``
407
+ GMT will automatically detect standard image files (Geotiff, TIFF,
408
+ JPG, PNG, GIF, etc.) and will read those via GDAL. For very obscure
409
+ image formats you may need to explicitly set *img_in*, which
410
+ specifies that the grid is in fact an image file to be read via
411
+ GDAL. Append **r** to assign the region specified by *region*
412
+ to the image. For example, if you have used ``region='d'`` then the
413
+ image will be assigned a global domain. This mode allows you to
414
+ project a raw image (an image without referencing coordinates).
415
+ dpi : int
416
+ ``[i|dpi]``.
417
+ Sets the resolution of the projected grid that will be created if a
418
+ map projection other than Linear or Mercator was selected [100]. By
419
+ default, the projected grid will be of the same size (rows and
420
+ columns) as the input file. Specify **i** to use the PostScript
421
+ image operator to interpolate the image at the device resolution.
422
+ bit_color : str
423
+ ``color[+b|f]``.
424
+ This option only applies when a resulting 1-bit image otherwise
425
+ would consist of only two colors: black (0) and white (255). If so,
426
+ this option will instead use the image as a transparent mask and
427
+ paint the mask with the given color. Append **+b** to paint the
428
+ background pixels (1) or **+f** for the foreground pixels
429
+ [Default].
430
+ shading : str
431
+ ``[intensfile|intensity|modifiers]``.
432
+ Give the name of a grid file with intensities in the (-1,+1) range,
433
+ or a constant intensity to apply everywhere (affects the ambient
434
+ light). Alternatively, derive an intensity grid from the input data
435
+ grid via a call to `grdgradient`; append **+a**\\ *azimuth*,
436
+ **+n**\\ *args*, and **+m**\\ *ambient* to specify azimuth,
437
+ intensity, and ambient arguments for that module, or just give
438
+ **+d** to select the default arguments (``+a-45+nt1+m0``). If you
439
+ want a more specific intensity scenario then run `grdgradient`
440
+ separately first. If we should derive intensities from another file
441
+ than grid, specify the file with suitable modifiers [Default is no
442
+ illumination].
443
+ {J}
444
+ monochrome : bool
445
+ Force conversion to monochrome image using the (television) YIQ
446
+ transformation. Cannot be used with *nan_transparent*.
447
+ no_clip : bool
448
+ Do not clip the image at the map boundary (only relevant for
449
+ non-rectangular maps).
450
+ nan_transparent : bool
451
+ Make grid nodes with z = NaN transparent, using the color-masking
452
+ feature in PostScript Level 3 (the PS device must support PS Level
453
+ 3).
454
+ {R}
455
+ {V}
348
456
{XY}
457
+ {n}
349
458
{p}
350
459
{t}
351
460
{x}
0 commit comments