2

I am using Google Earth Engine Python API to claculate NDVI and Export the result in Google Drive / Google Cloud storage (bucket). I am using the following code to export data to Cloud

task = Export.map.toCloudStorage(
    image = toexport,
    #image = SAVI.visualize({min:0, max:255}),
    description = 'Automation',
    scale = 20,
    bucket = 'gisagnext',
    #fileNamePrefix = 'Automation',
    #path = 'savi/',
    path = 'clip/',
    #path = 'ndvi',
    fileFormat = 'png',
    writePublicTiles = 'true',
    maxZoom = 14,
    minZoom = 4,
    #scale = 20,
    #region = row
    region = geometry1
    #maxPixcels=76904329300
    )
task.start()

Now I want to track back the exact time duration of sending data to Google Cloud in Python API.

1 Answer 1

3

You can monitor any batch task by periodically querying the task status. Below is an example, similar to the code in your question.

Setup some example data:

# Define an example image.
my_image = ee.Image("CGIAR/SRTM90_V4")
toexport = my_image.visualize(**{ 'min': 1000, 'max': 3000 })

# Define an export region.
region = ee.Geometry.Point(-112.1401, 36.0589).buffer(10000).bounds()
geometry1 = region.getInfo()['coordinates']

Initiate the task:

task = ee.batch.Export.map.toCloudStorage(
  image=toexport,
  region=geometry1,
  description = 'Automation',
  scale = 20,
  bucket = 'my-bucket-name',
  path = 'test_export_map/',
  fileFormat = 'png',
  writePublicTiles = 'true',
)
task.start()

Periodically poll the task status, until it is no longer running:

# Monitor the task.
while task.status()['state'] in ['READY', 'RUNNING']:
  print(task.status())
  time.sleep(10)
else:
  print(task.status())

For more information, see the Task object's status method.

1
  • Thanks, but is it possible without tracking?
    – Avik Betal
    Commented Jan 25, 2019 at 13:14

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.