Geographic Information Systems Asked on May 15, 2021
I am trying to extract the date as a string from an image in google earth engine, but can’t seem to get it right. This is the code I have so far.
date = ee.Date(image.get('system:time_start'))
This returns an ee.date
object in Python, but I can’t find the right way to access the object. Date.getInfo()
returns an error.
Does anyone know how to do this?
It is possible the access the date in the following way:
import ee
ee.Initialize()
collection = ee.ImageCollection('LANDSAT/LC08/C01/T1')
date = ee.Date(collection.first().get('system:time_start'))
date_dict = date.getInfo()
print "The number of milliseconds since 1970-01-01T00:00:00Z.: ", date_dict['value']
print "Formatted date", date.format('Y-M-d').getInfo()
Just calling ".getInfo()" on the ee.Date object will give you the number of milliseconds since 1970-01-01 in a Python dictionary.
It is possible to format the date with the ".format" method.
Answered by Bert Coerver on May 15, 2021
ee.Date(image.get('system:time_start')).format("yyyy-MM-dd")
Answered by Javad Koohpayma on May 15, 2021
Get help from others!
Recent Questions
Recent Answers
© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP