plot_by_regions#

geetools.ImageAccessor.plot_by_regions(type, regions, reducer='mean', bands=[], regionId='system:index', labels=[], colors=[], ax=None, scale=10000, crs=None, crsTransform=None, tileScale=1)#

Plot the reduced values for each region.

Each region will be plotted using the regionId as x-axis label defauting to “system:index” if not provided. If no bands are provided, all bands will be plotted. If no labels are provided, the band names will be used.

Warning

This method is client-side.

Parameters:
  • type (str) – The type of plot to use. Defaults to “bar”. can be any type of plot from the python lib matplotlib.pyplot. If the one you need is missing open an issue!

  • regions (ee.FeatureCollection) – The regions to compute the reducer in.

  • rreducer – The name of the reducer or a reducer object to use. Default is “mean”.

  • bands (list) – The bands to compute the reducer on. Default to all bands.

  • regionId (str) – The property used to label region. Defaults to “system:index”.

  • labels (list) – The labels to use for the output dictionary. Default to the band names.

  • colors (list) – The colors to use for the plot. Default to the default matplotlib colors.

  • ax (matplotlib.axes.Axes | None) – The matplotlib axis to plot the data on. If None, a new figure is created.

  • scale (int) – The scale to use for the computation. Default is 10000m.

  • crs (str | None) – The projection to work in. If unspecified, the projection of the image’s first band is used. If specified in addition to scale, rescaled to the specified scale.

  • crsTransform (list | None) – The list of CRS transform values. This is a row-major ordering of the 3x2 transform matrix. This option is mutually exclusive with ‘scale’, and replaces any transform already set on the projection.

  • tileScale (float) – A scaling factor between 0.1 and 16 used to adjust aggregation tile size; setting a larger tileScale (e.g., 2 or 4) uses smaller tiles and may enable computations that run out of memory with the default.

  • reducer (str | ee.Reducer)

Returns:

The matplotlib axis with the plot.

Return type:

matplotlib.axes.Axes

See also

  • byRegions: Compute a reducer in each region of the image for eah band.

  • byBands: Compute a reducer for each band of the image in each region.

  • plot_by_bands: Plot the reduced values for each bands.

  • :docstring:`ee.Image.geetools.plot_hist

Examples

import ee, geetools

ee.Initialize()

ecoregions = ee.FeatureCollection("projects/google/charts_feature_example").select(["label", "value","warm"])
normClim = ee.ImageCollection('OREGONSTATE/PRISM/Norm91m').toBands()


normClim.plot_by_regions(ecoregions, ee.Reducer.mean(), scale=10000)