Google Earth Engine

GEE Access and JavaScript Tips


Teaching: 0 min
Exercises: 0 min
  • How do I get an account?

  • What are some JavaScript basics?

  • Gain access to Google Earth Engine

  • Have a JavaScript resource


Use the steps below to register for a Google Earth Engine account and to join our shared repository.

1. Registering for a Google Earth Engine account

Not sure if you have access? Use this link to check. If you didn’t get access you will get an authorization error that says your account isn’t registered. If you do have access, the link will open up the Javascript IDE. This link is your permanent portal to GEE access.

2. Joining our shared GEE code repository

Google Earth Engine allows you to have shared group folders/repositories for scripts. Use the following link to access the workshop material. The course material is an updated version of the material developed for the geohackweek 2018. Open the shared repository by clicking this link:

3. Javascript Tips

JavaScript, not to be confused with Java, is a programming language widely used in web development alongside HTML and CSS. In this course we access Google Earth Engine by entering JavaScript commands into an online integrated development environment (IDE) called the Code Editor. It is not necessary to formally learn JavaScript to work with Google Earth Engine.

There are many online tutorials for learning JavaScript, but the Introduction to JavaScript for Earth Engine guide is most applicable if you want to learn more after this course. Below we provide examples and resources for getting started.

Basic JavaScript for GEE

Here are a few basics useful for GEE, reproduced from the Earth Engine 101 Beginner’s Curriculum.

// 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 are used to store objects and are defined using the keyword var.

var theAnswer = 42;

// string objects start and end with a single quote
var myVariable = 'I am a string';

// string objects can also use double quotes, but don't mix and match
var myOtherVariable = "I am also a string";

Statements should end in a semi-colon, or the editor complains.

var test = 'I feel incomplete...'
var test2 = 'I feel complete!';

Passing function parameters and using lists

// Parentheses are used 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 = ['eggplant','apple','wheat'];
print(myList[0]); // would print 'eggplant'

Using dictionaries

// Curly brackets (or braces) can be used to define dictionaries (key:value pairs).
var myDict = {'food':'bread', 'color':'red', 'number':42};

// Square brackets can be used to access dictionary items by key.

//Or you can use the dot notation to get the same result.

Functions can be defined as a way to reuse code and make it easier to read.

var myHelloFunction = function(string) {
  return 'Hello ' + string + '!';

Other JavaScript Resources

JavaScript uses camelCase. JavaScript (according to W3 academy) is easy to learn. Like other programming languages, you can use style guides to learn how to write standard, reproducible (marketable!) code.

For in-depth industry guidance, Google publishes their own definitive JavaScript style guide.

Google Earth Engine provides extensive guides and educational resources in case you want to learn more after this course.

Key Points