reduceRegion#
- geetools.ee_image_collection.ImageCollectionAccessor.reduceRegion(reducer, geometry, idProperty='system:index', idType=ee.Number, idReducer='first', idFormat=None, scale=None, crs=None, crsTransform=None, bestEffort=False, maxPixels=None, tileScale=1)#
Apply a reducer to all the pixels in a specific region on each image of the collection.
The result will be shaped as a dictionary with the idProperty as key and for each f them the reduced band values.
{ "image1": {"band1": value1, "band2": value2, ...}, "image2": {"band1": value1, "band2": value2, ...}, }
Warning
The method makes a call to the pure Python
uuidpackage so it cannot be used in a server-sidemapfunction.- Parameters:
idProperty (str) – The property to use as the key of the resulting dictionary. If not specified, the key of the dictionary is the index of the image in the collection. One should use a meaningful property to avoid conflicts. in case of conflicts, the images with the same property will be mosaicked together (e.g. all raw satellite imagery with the same date) to make sure the final reducer have 1 single entry per idProperty.
reducer (str) – THe reducer to apply.
idType (type) – The type of the idProperty. Default is ee.Number. As Dates are stored as numbers in metadata, we need to know what parsing to apply to the property in advance.
idReducer (str | ee.Reducer) – If the multiple images have the same idProperty, they will be aggregated beforehand using the provided reducer. default to a mosaic behaviour to match most of the satellite imagery collection where the world is split for each date between multiple images.
idFormat (str | ee.String | None) – If a date format is used for the IdProperty, the values will be formatted as “YYYY-MM-ddThh-mm-ss”. If a number format is used for the IdProperty, the values will be formatted as a string (“%s”). You can specify any other format compatible with band names.
geometry (ee.Geometry) – The region over which to reduce the data.
scale (int | float | None) – A nominal scale in meters to work in.
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 – 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.
bestEffort (bool) – If the polygon would contain too many pixels at the given scale, compute and use a larger scale which would allow the operation to succeed.
maxPixels (int | None) – The maximum number of pixels to reduce.
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.
crsTransform (list | None)
- Returns:
A dictionary with the reduced values for each image.
- Return type:
Examples
import ee, geetools ee.Initialize() collection = ( ee.ImageCollection("LANDSAT/LC08/C01/T1_TOA") .filterBounds(ee.Geometry.Point(-122.262, 37.8719)) .filterDate("2014-01-01", "2014-12-31") ) data = collection.geetools.reduceRegion("mean", geometry=ee.Geometry.Point(-122.262, 37.8719), scale=30) print(data.getInfo())