Sample GEE test scripts for the vscode EE Tasks extension
This repository contains sample GEE scripts that have been tested to work with the vscode EE Tasks extension.
Read more about how to use the EE Tasks: run GEE script
command here.
In addition, it contains some small related node scripts, including one that demonstrates the authentication and initialization of the earthengine JavaScript API.
Here's a demonstration of the extension capabilities:
To run these scripts in vscode, first install the EE Tasks vscode extension and follow the sign in instructions.
Finally, open the script to run, press F1
and type EE Tasks: run GEE script
.
- helloGEE: demonstrates the use of
print
either directly or as a callback function in.getInfo()
- ExportTableToDrive: demonstrates a simple Export.table.toDrive with a call to Map.addLayer ignored.
- ExportImageToDrive: demonstrates a simple Export.Image.toDrive.
- MapAddLayer: demonstrates the new capability for opening an interactive Map, adding ee layers, and exporting a single image in the same script.
The helloNodeGEE.js is a minimal node script demonstrating the authentication and initialization of the EE library with one asynchronous and one synchronous request. It requires a valid access_token.
If you have stored credentials generated by the python Earth Engine client (~/.config/earthengine/credentials
), then you can generate a token (valid for one hour) using the printToken.js
node script.
The following instructions are not required to run the sample GEE scripts within the vscode EE Tasks extension.
You will need to use npm to install the google/earthengine JavaScript API.
npm install @google/earthengine
Next, generate the token:
node printToken.js
If a valid token is generated, the output should look like this:
{
access_token: 'ya29...<VERY LONG STRING HERE>...',
expires_in: 3599,
scope: 'https://www.googleapis.com/auth/earthengine https://www.googleapis.com/auth/devstorage.full_control',
token_type: 'Bearer'
}
Copy the access_token
string and export the EETOKEN
environment variable:
export EETOKEN="ya29...<VERY LONG STRING HERE>..."
Finally, run the example:
node helloNodeGEE.js
The output should look like this:
$ node helloNodeGEE.js
Hello from synchronous request
Hello from callback