Access GEE code editor at https://code.earthengine.google.com/
Dan Dixon
- GEE Introductory Overview ~ 1 h 10 min
- Wrapping Up ~ 20 min
- Q&A ~
- Get a GMAIL/GOOGLE account
- Sign up for Earth Engine (http://bit.ly/GoogEEngine).
- Registration is needed to have access to EE
- If registered, verify your GEE access though the link below
We assume everyone is registered and have access to GEE
Otherwise, just follow the discussion and try on your own time
Earth Engine Developer's Page https://developers.google.com/earth-engine
- Guides - JavaScript & Python
- Reference - Client Libraries & Code Editor
- Help & Support
- Data Catalog, etc.
Questions |
---|
|
Learning Points |
---|
|
A cloud-based platform for planetary-scale geospatial analysis
An interactive environment for development at scale |
---|
- Fast prototyping & computation
- Easy dissemination of research outputs through GEE Apps
- High-impact & data-driven science
- Free cloud processing with built-in functions optimized for parallel computing
Online public data archive$~$ |
---|
- A petabyte (> 50) storage accessible through GEE APIs
- Unfortunately, ocean colour data repository still very poor
However...
> We can upload own datasets (up to 10 GB)
> Make dataset requests
Flexible access through APIs
Rapid visualization of complex spatial analyses
API → application programming interface
How GEE works |
---|
Server-side |
Written commands can be sent as requests object to Google's cloud for compution |
Client-side |
Results sent back can be visualized in the browser |
Aim to tackle some of the world’s greatest challenges using open Earth data
Summary
-
GEE is great tool operating on petabyte imagery using Google’s cloud
-
Allows complex analysis and visualizations with basic JavaScript
-
Eliminates most of the hurdles with satellite data analysis
→ e.g., downloading, data formats, etc (not so for ocean colour) -
Easy dissemination of output results through GEE Apps
-
Allows import/export of your own assets
→ raster and vector data, e.g., projected swath or in situ data points -
GEE is changing the way we study and understand the Earth
-
Only works with internet connection
-
Users have no control on how computations are run in GEE
-
Non-parallelizable operations cannot be performed effectively
-
GEE performs poorly for long-running iterative processes
→ e.g. finite element, etc.
questions if any |
---|
GEE Code Editor |
Questions |
---|
|
Learning Points |
---|
|
## Code Editor
Summary
-
The Code Editor provides an easy and abstract way to
-
accessing GEE data catalog as well as personal assets
-
conducting geospatial analysis
-
displaying and sharing the results
-
Provide ways to import, export, share and manage personal assets
-
Example scripts, Docs and help are valuable resources to explore
Questions |
---|
|
Learning Points |
---|
|
// And, the first thing you do in any programming language:
print('Hello World!')
// Line comments start with two forward slashes. Like this line.
/* Multi-line comments start with a forward slash and a star,
and end with a star and a forward slash. */
// variables store objects and are defined using the keyword var
var thisNumber = 1;
// string objects start and end with a single quote
var thisString = 'I am a string';
// string objects can also use double quotes
// But don't mix the two
var thatString = "I am a string";
// statements end with a semi-colon, or the editor will complain
var feelsIncomplete = "I feel incomplete..."
var feelsComplete = "I feel complete!";
// use parentheses to pass parameters to functions
print('This string will print in the Console tab.');
/* square brackets are used for items in a list
The zero index refers to the first item in a list*/
var myList = ['corn','wheat','soybeans'];
print(myList[0]);
print(myList[3]);
/* Use curly brackets (or braces) to define dictionaries
{key:value} pairs. */
var myDict = {'food':'bread', 'color':"red", 'number':42};
// Use square brackets to access dictionary items by key
print(myDict['color']);
//Or use the dot notation to get the same result
print(myDict.color);
/*function can be defined as a way to reuse
code and make it easier to read*/
var myHelloFunction = function(string) {
return 'Hello ' + string + '!';
};
print(myHelloFunction('world'));
- Everything we saw so far lives in the browser (client-side)
- Client-side useful, for example, when making EE user interfaces
- Server-side objects are proxy objects and start with
ee
→ Server-side (proxy) objects are just handles for objects on the server
var clientString = 'I am a String';
print(typeof clientString); // string
var serverString = ee.String('I am not a String!');
print(typeof serverString); // object
print('Is this an EE object?',
serverString instanceof ee.ComputedObject); // true
/* Observe that "serverString" is an "object",
more specifically, "ee.computedObject" */
/* Client doesn't know what's in the container,
so we can find out by printing it */
print(serverString); // I am not a String
/* To see what the container itself looks like,
call toString() on the object: */
print(serverString.toString());
// ee.String("I am not a String!")
/* we can get the contents of the container
and assign them to a variable */
var someString = serverString.getInfo();
var strings = someString + ' Am I?';
print(strings); // I am not a String! Am I?
/* getInfo() is synchronous, thus it blocks code execution,
so should avoid using it unless absolutely needed */
var something = ee.thing.getInfo(); // synchronous call
// A good way to request a value of the server object is to use
// evaluate() - this call is asynchronous
ee.Number(7).evaluate(function(n) {
var clientNum = n + 3;
print('Should be 10. Found ' + clientNum);
});
// This exists in the browser
var clientList = [0, 1, 2, 3, 4, 5, 6, 7];
print(clientList);
// This is a handle for some object on the cloud
var serverList = ee.List(clientList);
print(serverList); // They look the same!
var anotherList = ee.List.sequence(0, 7);
print(anotherList); // Also the same!
// Client-side objects are mutable
clientList.push(8);
print(clientList);
// However, the same won't work on the server list
// serverList.push(8); // Error!
var longerList = serverList.add(8);
// Use docs tab to discover methods on server objects
// A constant Image
var constantImage = ee.Image(7);
// This is NOT what we want:
var junkString = constantImage + 42;
/* Note that the browser calls toString() on the object and
then appends '42' to it. The JSON you see contains the
instructions sent to the server to execute your code */
print('JunkString:', junkString);
// This is the right way:
var someImage = constantImage.add(42);
// Click with the inspector to observe
Map.addLayer(someImage, {}, 'someImage')
- In EE we use
map()
instead offor-loops
- This is key to making EE work
for-loops
may still be useful for client-side (user interfaces)- However, server-side is best served with
map
.map(...)
vs. for(...)
Summary
- In EE computations are parallel (
map
instead offor
) .getInfo()
can cause browser lock (.evaluate
instead)- Mixing client and server functions can cause errors
- Cast client into server objects using the
ee.Thing
constructor
e.g., ee.List([1, 2]), etc.
- Server-side objects are immutable. Save changes in a new object
- i.e., assign the changes to a new variable
e.g., var newImage = oldImage.add(3)
Additional JavaScript Resources |
---|
Reduce - Aggregate everything in a collection
reducer - an EE operation for aggregating data or computing a statistic
Apply a reducer over an image with several bands
Questions |
---|
|
Learning Points |
---|
|
- Introductory Overview to GEE
- GEE Code Editor: How to navigate the code editor
- Basics JavaScript: What is client-side and server-side
Code Editor: Where you go to write code.
- This is the best tools for development
- Also, check Help (?) inside the Code Editor, it provides links to useful pages
Data Catalogue: Details on the available datasets
- Ocean colour datasets are still in their infancy (far behind land-group)
- By building a strong (or larger) community progress can be achieved relaively faster
Developers Guide: the closest thing to a manual
- Other than documentation, this provides useful links to many other resources
Developers Forum: Where you go to post questions
- If you plan on using GEE, it is advisable to join the EE Forum
- When posting questions in this forum, include a link to your script for others to help you troubleshoot more easily
- Code sharing
- Any private asset in the shared script is only accessible to those allowed of if it is puclic
- Debugging Guide
- Earth Engine EDU
- Some materials have also been translated to Japanese
- GeoHackWeek