Skip to content

Latest commit

 

History

History
83 lines (40 loc) · 4.92 KB

runGEEscripts.md

File metadata and controls

83 lines (40 loc) · 4.92 KB

Run GEE scripts from vscode!

Hello world

Use the EE Tasks: run GEE script command to run the GEE script open in the Editor using a user account/project. For example:

hellogee

The EE Tasks: run GEE script (service account) is also available to run scripts using a valid private key (JSON file).

upon picking an available account (and project, if required), the script is started. If successful, the output will open in a channel called "EE Tasks: GEE script runs":

hellogee-log

GEE script definition

For the purpose of this document, a "GEE script" is a .js file that is able to run in the Earth Engine Code Editor.

❗ Not all GEE scripts can be run here.

The EE Tasks extension wraps your code in a function that handles the initialization of ee, as well as providing some of the extra features in the Earth Engine Code Editor, including print, Export (e.g. Export.table.toDrive), and Map.addLayer. Here's a list of what is available.

Submit tasks directly from vscode

If your script uses any of the supported Export commands, your tasks will be submitted automatically and you can monitor the tasks using the EE Tasks: view tasks command.

The following animation shows an example that submits a single Export.image.toDrive task. A notification then informs the user that the task was submitted successfully. Then, the task can be monitored with the EE Tasks: view tasks command.

eetasks-readme

Show EE layers in an interacive map

The animation above also shows the capability of adding EE layers to an interactive map, which supports ee.Image, ee.ImageCollection, ee.Geometry, ee.Feature, and ee.FeatureCollection.

Client-side errors

Client-side errors (errors in your script not related to EE) will be shown in an error notification:

hellogee-log

Features

print

print somewhat mirrors the functionality of print in the Code Editor:

⚠️ Print for eeObjects wraps getInfo in asynchronous mode, so the order appearing in the output is not guaranteed❗. Use print(myEeObject.getInfo()) if you want the script to perform the print synchronously.

ExportTableSuccessFail

Export

All Export features mirror the functionality from the Code Editor (in fact, they wrap the ee.batch.Export* methods). However,

⚠️ In contrast to the Code Editor, tasks will be automatically submitted.

For example:

ExportTableSuccessFail

⚠️ Another contrast to the Code Editor can be seen in the example above. In the Code Editor, some parameters such as assetId, bucket, etc. are prompted from the user after clicking "Run". Here, the task fails to start if they are not provided explicitly.

We can then use the EE Tasks: view command to monitor the task:

ExportTableTaskCompleted

We can see that the task completed, demonstrating task submission and monitoring from vscode!

Map

Currently, only Map.setCenter and Map.addLayer have been implemented. If your script uses any of these two commands, a leaflet map will open, and if your script uses Map.addLayer, the layers should be added to the map. The Map features a simple control for the opacity (slider) and visibility (checkbox) of each layer.

ExportTableTaskCompleted

Any other Map commands will be silently ignored

Excluded

Any other extra features that the Code Editor provides, such as ui.Chart (or other ui features) are not yet implemented, but will be silently ignored.