GEE批量提交任务最新代码

国外大佬Mathieu Gravey制作了一个谷歌浏览器的插件,叫做Open Earth Engine extension,实现一键run,简单高效,谁用谁知道。谷歌搜索可得:


在用GEE进行多站点多时间序列批量下载数据等操作时往往需要提交大量任务,逐一点击Run耗时耗力。中山大学Dongdong Kong在2017年率先编写了批量运行GEE任务的代码,但是由于GEE版本更新在2021年9月中旬之后,该代码无法运行。yzq.yang在Kong的基础上更新了代码,亲测可用,代码如下:
代码1

/**
 * Copyright (c) 2017 Dongdong Kong. All rights reserved.
 * This work is licensed under the terms of the MIT license.  
 * For a copy, see .
 *
 * 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
 *  yzq.yang, 17 Sep' 2021
 */
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();
    $$('.run-button' ,$$('ee-task-pane')[0].shadowRoot).forEach(function(e) {
         e.click();
    })
}

function confirmAll() {
    // var ok = document.getElementsByClassName('goog-buttonset-default goog-buttonset-action');
    // for (var i = 0; i < ok.length; i++)
    //     ok[i].click();
    $$('ee-table-config-dialog, ee-image-config-dialog').forEach(function(e) {
         var eeDialog = $$('ee-dialog', e.shadowRoot)[0]
         var paperDialog = $$('paper-dialog', eeDialog.shadowRoot)[0]
         $$('.ok-button', paperDialog)[0].click()
    })
}

代码2

runTaskList();

代码3

confirmAll();

使用方法:
在GEE平台提交任务后(图1),F12调出控制台,将代码1复制到控制台中(图2),按Enter运行。然后再运行代码2,稍等片刻浏览器会弹出确认的窗口(图3),此时再运行代码3即可。

图1.提交任务后

图2.代码1在控制台运行后

图3.代码2在控制台输入后弹出确认窗口

特别致谢中山大学Dongdong Kong,yzq.yang的代码编写以及Li Wenzhao等在gis.stackexchange的讨论

文章来源:https://gis.stackexchange.com/questions/290771/batch-task-execution-in-google-earth-engine

你可能感兴趣的:(GEE批量提交任务最新代码)