wxee.xarray.DatasetAccessor.rgb
- DatasetAccessor.rgb(bands: List[str] | None = None, stretch: float = 1.0, interactive: bool = False, **kwargs: Any) Any [source]
Generate an RGB color composite plot of the Dataset.
- Parameters:
bands (List[str], optional) – A list of 3 data variable names to use as the red, green, and blue channels. If none is provided, the first three data variables will be used in order.
stretch (float, default 1.0) – A percentile stretch to apply to pixel values, between 0.0 and 1.0.
interactive (bool, default False) – If False, a static plot is returned, faceted over the time dimension. If True, an interactive plot is returned over the time dimension. interactive plots require the hvplot library to be installed independently.
**kwargs – Keyword arguments passed to the plotting function. For static plots, arguments are passed to
xarray.Dataset.plot.imshow
. For interactive plots, arguments are passed toxarray.Dataset.hvplot.rgb
.
- Returns:
The RGB plot, either static or interactive.
- Return type:
Union[xarray.plot.facetgrid.FacetGrid, HoloViews object]
- Raises:
ValueError – If an incorrect number of bands are found, whether explicitly passed through the bands argument or implicitly identified from the data variables.
ImportError – If the interactive argument is True and the hvplot package is not installed.
Examples
Download one month of Sentinel-2 imagery over a point.
>>> pt = ee.Geometry.Point([5.40432,44.11541]) >>> ts = wxee.TimeSeries("COPERNICUS/S2_SR") >>> ts = ts.filterDate("2020-07", "2020-08").filterBounds(pt) >>> ds = ts.wx.to_xarray(region=pt.buffer(1000), scale=20)
Generate a static plot of the images as a true color composite. The col_wrap argument will be passed to the plotting function.
>>> ds.wx.rgb(bands=["B4", "B3", "B2"], stretch=0.85, col_wrap=4)
Generate an interactive plot using a near-infrared false color composite. The aspect argument will be passed to the plotting function.
>>> ds.wx.rgb(bands=["B8", "B4", "B3"], stretch=0.85, interactive=True, aspect=1.2)