geetools.ImageAccessor.addDate#
- geetools.ImageAccessor.addDate(format='')#
Add a band with the date of the image in the provided format.
If no format is provided, the date is stored as a Timestamp in millisecond in a band “date”. If format band is provided, the date is store in a int8 band with the date in the provided format. This format needs to be a string that can be converted to a number. If not an error will be thrown.
- Parameters:
format (geetools.types.ee_str) – A date pattern, as described at http://joda-time.sourceforge.net/apidocs/org/joda/time/format/DateTimeFormat.html
- Returns:
The image with the date band added.
- Return type:
ee.Image
Examples
import ee, geetools ee.Initialize() image = ee.Image('COPERNICUS/S2_SR_HARMONIZED/20200101T100319_20200101T100321_T32TQM') image = image.geetools.addDate() date = image.select('date') buffer = ee.Geometry.Point([12.4534, 41.9033]).buffer(100) value = date.reduceRegion(ee.Reducer.first(), buffer, 10).get("date") ee.Date(value).format('YYYY-MM-dd').getInfo()