closest#

geetools.ee_image_collection.ImageCollectionAccessor.closest(date, tolerance=1, unit='month')#

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

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

  • tolerance (int) – 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 (str) – 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
import geetools

s2 = ee.ImageCollection('COPERNICUS/S2_SR').closest('2020-10-15')
s2.size().getInfo()