TransWikia.com

Batch task execution in google earth engine

Geographic Information Systems Asked on January 1, 2021

I need to make tens of clipped portions of an image, so I uploaded the boundaries in my assets and then loaded them all in code editor and did the clips with a for loop and exported them to the cloud. It will add a list of all the tasks in my task pane, but still I should go and run each of them individually. Is there any way to run all the tasks at once?

2 Answers

If you absolutely need to use the Code Editor for batch exports there are hacks to click all the "Run Task" buttons for you. Word of caution: the preferred and more stable way to do batch exports is the Python API or change the code to export all your assets with one export statement.

One way is to use Dongdong Kong's GEE Monkey which uses the Tampermonkey plugin in your browser to add a "run all" button.

The other would be to use his script directly, that he posted on the GEE developer board:

/**
 * Batch execute GEE Export task
 *
 * First of all, You need to generate export tasks. And run button was shown.
 *   
 * Then press F12 get into console, then paste those scripts in it, and press 
 * enter. All the task will be start automatically. 
 * (Firefox and Chrome are supported. Other Browsers I didn't test.)
 * 
 * @Author: 
 *  Dongdong Kong , 28 Aug' 2017 
 *      Sun Yat-sen University
 */
function runTaskList(){
    var tasklist = document.getElementsByClassName('task local type-EXPORT_IMAGE awaiting-user-config');
    for (var i = 0; i < tasklist.length; i++)
            tasklist[i].getElementsByClassName('run-button')[0].click();
}

function confirmAll() {
    var ok = document.getElementsByClassName('goog-buttonset-default goog-buttonset-action');
    for (var i = 0; i < ok.length; i++)
        ok[i].click();
}

runTaskList();
confirmAll();

Correct answer by Kersten on January 1, 2021

You can also wrap it up into one function with a pause between each task. This ensures that the Asset directory loads before the next "Run" button is activated.

function runTask() {

    var tasklist = document.getElementsByClassName('task local type-EXPORT_IMAGE awaiting-user-config');
    
    if (tasklist.length == 0)
        return;
    
    tasklist[0].getElementsByClassName('run-button')[0].click();
    
    setTimeout(function() {
      
      var ok = document.getElementsByClassName('goog-buttonset-default goog-buttonset-action');
      
      if (ok.length == 0)
        return;
      
      ok[0].click();
      
      setTimeout(runTask, 2000);
      
    }, 2000);
}
runTask()

Answered by Zander Venter on January 1, 2021

Add your own answers!

Ask a Question

Get help from others!

© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP