ee.ImageCollection

Extended methods for the ee.ImageCollection class:

eemont.imagecollection.closest(self, date, tolerance=1, unit='month')[source]

Gets the closest image (or set of images if the collection intersects a region that requires multiple scenes) to the specified date.

Parameters
  • self (ee.ImageCollection [this]) – Image Collection from which to get the closest image to the specified date.

  • date (ee.Date | string) – Date of interest. The method will look for images closest to this date.

  • tolerance (float, default = 1) – Filter the collection to [date - tolerance, date + tolerance) before searching the closest image. This speeds up the searching process for collections with a high temporal resolution.

  • unit (string, default = 'month') – Units for tolerance. Available units: ‘year’, ‘month’, ‘week’, ‘day’, ‘hour’, ‘minute’ or ‘second’.

Returns

Closest images to the specified date.

Return type

ee.ImageCollection

Examples

>>> import ee, eemont
>>> ee.Initialize()
>>> S2 = ee.ImageCollection('COPERNICUS/S2_SR').closest('2020-10-15')
eemont.imagecollection.getTimeSeriesByRegion(self, reducer, bands=None, geometry=None, scale=None, crs=None, crsTransform=None, bestEffort=False, maxPixels=1000000000000.0, tileScale=1, dateColumn='date', dateFormat='ISO', naValue=- 9999)[source]

Gets the time series by region for the given image collection and geometry (feature or feature collection are also supported) according to the specified reducer (or reducers).

Parameters
  • self (ee.ImageCollection (this)) – Image collection to get the time series from.

  • reducer (ee.Reducer | list[ee.Reducer]) – Reducer or list of reducers to use for region reduction.

  • bands (str | list[str], default = None) – Selection of bands to get the time series from. Defaults to all bands in the image collection.

  • geometry (ee.Geometry | ee.Feature | ee.FeatureCollection, default = None) – Geometry to perform the region reduction. If ee.Feature or ee.FeatureCollection, the geometry() method is called. In order to get reductions by each feature please see the getTimeSeriesByRegions() method. Defaults to the footprint of the first band for each image in the collection.

  • scale (numeric, default = None) – Nomical scale in meters.

  • crs (Projection, default = 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, default = 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.

  • bestEffort (boolean, default = False) – 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 (numeric, default = 1e12) – The maximum number of pixels to reduce.

  • tileScale (numeric, default = 1) – A scaling factor used to reduce aggregation tile size; using a larger tileScale (e.g. 2 or 4) may enable computations that run out of memory with the default.

  • dateColumn (str, default = 'date') – Output name of the date column.

  • dateFormat (str, default = 'ISO') – Output format of the date column. Defaults to ISO. Available options: ‘ms’ (for milliseconds), ‘ISO’ (for ISO Standard Format) or a custom format pattern.

  • naValue (numeric, default = -9999) – Value to use as NA when the region reduction doesn’t retrieve a value due to masked pixels.

Returns

Time series by region retrieved as a Feature Collection.

Return type

ee.FeatureCollection

Examples

>>> import ee, eemont
>>> ee.Initialize()
>>> f1 = ee.Feature(ee.Geometry.Point([3.984770,48.767221]).buffer(50),{'ID':'A'})
>>> f2 = ee.Feature(ee.Geometry.Point([4.101367,48.748076]).buffer(50),{'ID':'B'})
>>> fc = ee.FeatureCollection([f1,f2])
>>> S2 = (ee.ImageCollection('COPERNICUS/S2_SR')
...      .filterBounds(fc)
...      .filterDate('2020-01-01','2021-01-01')
...      .maskClouds()
...      .scale()
...      .index(['EVI','NDVI']))
>>> ts = S2.getTimeSeriesByRegion(reducer = [ee.Reducer.mean(),ee.Reducer.median()],
...                               geometry = fc,
...                               bands = ['EVI','NDVI'],
...                               scale = 10)

See also

getTimeSeriesByRegions

Gets the time series by regions for the given image collection and feature collection according to the specified reducer (or reducers).

eemont.imagecollection.getTimeSeriesByRegions(self, reducer, collection, bands=None, scale=None, crs=None, crsTransform=None, tileScale=1, dateColumn='date', dateFormat='ISO', naValue=- 9999)[source]

Gets the time series by regions for the given image collection and feature collection according to the specified reducer (or reducers).

Parameters
  • self (ee.ImageCollection (this)) – Image collection to get the time series from.

  • reducer (ee.Reducer | list[ee.Reducer]) – Reducer or list of reducers to use for region reduction.

  • collection (ee.FeatureCollection) – Feature Collection to perform the reductions on. Image reductions are applied to each feature in the collection.

  • bands (str | list[str], default = None) – Selection of bands to get the time series from. Defaults to all bands in the image collection.

  • scale (numeric, default = None) – Nomical scale in meters.

  • crs (Projection, default = 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, default = 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 (numeric, default = 1) – A scaling factor used to reduce aggregation tile size; using a larger tileScale (e.g. 2 or 4) may enable computations that run out of memory with the default.

  • dateColumn (str, default = 'date') – Output name of the date column.

  • dateFormat (str, default = 'ISO') – Output format of the date column. Defaults to ISO. Available options: ‘ms’ (for milliseconds), ‘ISO’ (for ISO Standard Format) or a custom format pattern.

  • naValue (numeric, default = -9999) – Value to use as NA when the region reduction doesn’t retrieve a value due to masked pixels.

Returns

Time series by regions retrieved as a Feature Collection.

Return type

ee.FeatureCollection

Examples

>>> import ee, eemont
>>> ee.Initialize()
>>> f1 = ee.Feature(ee.Geometry.Point([3.984770,48.767221]).buffer(50),{'ID':'A'})
>>> f2 = ee.Feature(ee.Geometry.Point([4.101367,48.748076]).buffer(50),{'ID':'B'})
>>> fc = ee.FeatureCollection([f1,f2])
>>> S2 = (ee.ImageCollection('COPERNICUS/S2_SR')
...      .filterBounds(fc)
...      .filterDate('2020-01-01','2021-01-01')
...      .maskClouds()
...      .scale()
...      .index(['EVI','NDVI']))
>>> ts = S2.getTimeSeriesByRegions(reducer = [ee.Reducer.mean(),ee.Reducer.median()],
...                                collection = fc,
...                                bands = ['EVI','NDVI'],
...                                scale = 10)

See also

getTimeSeriesByRegion

Gets the time series by region for the given image collection and geometry (feature or feature collection are also supported) according to the specified reducer (or reducers).

eemont.imagecollection.index(self, index='NDVI', G=2.5, C1=6.0, C2=7.5, L=1.0)[source]

Computes one or more spectral indices (indices are added as bands) for an image collection.

Parameters
  • self (ee.ImageCollection) – Image collection to compute indices on. Must be scaled to [0,1]. Check the supported platforms in User Guide > Spectral Indices > Supported Platforms.

  • index (string | list[string], default = 'NDVI') –

    Index or list of indices to compute.

    Available options:
    • ’vegetation’ : Compute all vegetation indices.

    • ’burn’ : Compute all burn indices.

    • ’water’ : Compute all water indices.

    • ’snow’ : Compute all snow indices.

    • ’all’ : Compute all indices listed below.

    Vegetation indices:
    • ’BNDVI’ : Blue Normalized Difference Vegetation Index.

    • ’CIG’ : Chlorophyll Index - Green.

    • ’CVI’ : Chlorophyll Vegetation Index.

    • ’EVI’ : Enhanced Vegetation Index.

    • ’EVI2’ : Two-Band Enhanced Vegetation Index.

    • ’GBNDVI’ : Green-Blue Normalized Difference Vegetation Index.

    • ’GNDVI’ : Green Normalized Difference Vegetation Index.

    • ’GRNDVI’ : Green-Red Normalized Difference Vegetation Index.

    • ’MNDVI’ : Modified Normalized Difference Vegetation Index.

    • ’NDVI’ : Normalized Difference Vegetation Index.

    • ’NGRDI’ : Normalized Green Red Difference Index.

    • ’RVI’ : Ratio Vegetation Index.

    • ’SAVI’ : Soil-Adjusted Vegetation Index.

    Burn and fire indices:
    • ’BAI’ : Burned Area Index.

    • ’BAIS2’ : Burned Area Index for Sentinel 2.

    • ’CSIT’ : Char Soil Index Thermal.

    • ’NBR’ : Normalized Burn Ratio.

    • ’NBRT’ : Normalized Burn Ratio Thermal.

    • ’NDVIT’ : Normalized Difference Vegetation Index Thermal

    • ’SAVIT’ : Soil-Adjusted Vegetation Index Thermal.

    Water indices:
    • ’MNDWI’ : Modified Normalized Difference Water Index.

    • ’NDWI’ : Normalized Difference Water Index.

    Snow indices:
    • ’NDSI’ : Normalized Difference Snow Index.

  • G (float, default = 2.5) – Gain factor. Used just for index = ‘EVI’.

  • C1 (float, default = 6.0) – Coefficient 1 for the aerosol resistance term. Used just for index = ‘EVI’.

  • C2 (float, default = 7.5) – Coefficient 2 for the aerosol resistance term. Used just for index = ‘EVI’.

  • L (float, default = 1.0) – Canopy background adjustment. Used just for index = [‘EVI’,’SAVI’].

Returns

Image collection with the computed spectral index, or indices, as new bands.

Return type

ee.ImageCollection

Examples

>>> import ee, eemont
>>> ee.Initialize()
>>> S2 = ee.ImageCollection('COPERNICUS/S2_SR').scale().index(['NDVI','EVI','GNDVI'])

See also

scale

Scales bands on an image collection.

eemont.imagecollection.maskClouds(self, method='cloud_prob', prob=60, maskCirrus=True, maskShadows=True, scaledImage=False, dark=0.15, cloudDist=1000, buffer=250, cdi=None)[source]

Masks clouds and shadows in an image collection (valid just for Surface Reflectance products).

Parameters
  • self (ee.ImageCollection [this]) – Image collection to mask. Check the supported platforms in User Guide > Masking Clouds and Shadows > Supported Platforms.

  • method (string, default = 'cloud_prob') –

    Method used to mask clouds.

    Available options:
    • ’cloud_prob’ : Use cloud probability.

    • ’qa’ : Use Quality Assessment band.

    This parameter is ignored for Landsat products.

  • prob (numeric [0, 100], default = 60) – Cloud probability threshold. Valid just for method = ‘prob’. This parameter is ignored for Landsat products.

  • maskCirrus (boolean, default = True) – Whether to mask cirrus clouds. Valid just for method = ‘qa’. This parameter is ignored for Landsat products.

  • maskShadows (boolean, default = True) – Whether to mask cloud shadows. For more info see ‘Braaten, J. 2020. Sentinel-2 Cloud Masking with s2cloudless. Google Earth Engine, Community Tutorials’.

  • scaledImage (boolean, default = False) – Whether the pixel values are scaled to the range [0,1] (reflectance values). This parameter is ignored for Landsat products.

  • dark (float [0,1], default = 0.15) – NIR threshold. NIR values below this threshold are potential cloud shadows. This parameter is ignored for Landsat products.

  • cloudDist (int, default = 1000) – Maximum distance in meters (m) to look for cloud shadows from cloud edges. This parameter is ignored for Landsat products.

  • buffer (int, default = 250) – Distance in meters (m) to dilate cloud and cloud shadows objects. This parameter is ignored for Landsat products.

  • cdi (float [-1,1], default = None) – Cloud Displacement Index threshold. Values below this threshold are considered potential clouds. A cdi = None means that the index is not used. For more info see ‘Frantz, D., HaS, E., Uhl, A., Stoffels, J., Hill, J. 2018. Improvement of the Fmask algorithm for Sentinel-2 images: Separating clouds from bright surfaces based on parallax effects. Remote Sensing of Environment 2015: 471-481’. This parameter is ignored for Landsat products.

Returns

Cloud-shadow masked image collection.

Return type

ee.ImageCollection

Examples

>>> import ee, eemont
>>> ee.Initialize()
>>> S2 = ee.ImageCollection('COPERNICUS/S2_SR').maskClouds(prob = 75,buffer = 300,cdi = -0.5)

Notes

This method may mask water as well as clouds for the Sentinel-3 Radiance product.

eemont.imagecollection.scale(self)[source]

Scales bands on an image collection.

Parameters

self (ee.ImageCollection (this)) – Image collection to scale. Check the supported platforms in User Guide > Image Scaling > Supported Platforms.

Returns

Scaled image collection.

Return type

ee.ImageCollection

Examples

>>> import ee, eemont
>>> ee.Initialize()
>>> S2 = ee.ImageCollection('COPERNICUS/S2_SR').scale()