Skip to content

Commit 6b61b93

Browse files
committed
Allow passing in Red, Green, Blue grids into grdimage
Using the sequence_space converter to allow for multiple grid inputs into `grdimage`. Useful when users want to make an RGB image plot e.g. from Landsat images (Bands 4,3,2).
1 parent 55af9b6 commit 6b61b93

File tree

3 files changed

+12
-3
lines changed

3 files changed

+12
-3
lines changed

pygmt/base_plotting.py

+4-3
Original file line numberDiff line numberDiff line change
@@ -288,22 +288,23 @@ def grdcontour(self, grid, **kwargs):
288288

289289
@fmt_docstring
290290
@use_alias(R="region", J="projection", W="pen", B="frame", I="shading", C="cmap")
291-
@kwargs_to_strings(R="sequence")
291+
@kwargs_to_strings(R="sequence", grid="sequence_space")
292292
def grdimage(self, grid, **kwargs):
293293
"""
294294
Project grids or images and plot them on maps.
295295
296296
Takes a grid file name or an xarray.DataArray object as input.
297+
Alternatively, pass in a list of red, green, blue grids to be imaged.
297298
298299
Full option list at :gmt-docs:`grdimage.html`
299300
300301
{aliases}
301302
302303
Parameters
303304
----------
304-
grid : str or xarray.DataArray
305+
grid : str, xarray.DataArray or list
305306
The file name of the input grid or the grid loaded as a DataArray.
306-
307+
A list of red, green, blue grids can also be provided instead.
307308
"""
308309
kwargs = self._preprocess(**kwargs)
309310
kind = data_kind(grid, None, None)
52.6 KB
Loading

pygmt/tests/test_grdimage.py

+8
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,14 @@ def test_grdimage_file():
4141
return fig
4242

4343

44+
@pytest.mark.mpl_image_compare
45+
def test_grdimage_rgb_files():
46+
"Plot an image using Red, Green, and Blue file inputs"
47+
fig = Figure()
48+
fig.grdimage(grid=["@earth_relief_60m", "@earth_relief_60m", "@earth_relief_60m"])
49+
return fig
50+
51+
4452
def test_grdimage_fails():
4553
"Should fail for unrecognized input"
4654
fig = Figure()

0 commit comments

Comments
 (0)