App Engine & Earth Engine Overview

Google App Engine lets you build and run your own custom applications on Google’s servers. App Engine applications are easy to create, maintain, and scale as your traffic and data storage needs change. You simply upload your application source code and it’s ready to go. If you're new to developing for App Engine, be sure to check out the App Engine Python tutorial before proceeding.

Earth Engine and App Engine can be used together to build scalable geospatial applications. Typically, your App Engine code includes the Earth Engine Python client library and makes requests to the Earth Engine backend using a service account. This is advantageous because it allows anyone to use your app without logging in or being a registered Earth Engine user. Note that the standard Earth Engine usage limits apply to each service account. If your application receives a lot of traffic, your service account may be temporarily blocked.

Another development approach is to use client-side authentication instead of a service account. With this approach, visitors to your application must be whitelisted for Earth Engine and log in. The benefit of this approach is that requests to Earth Engine are made by the end user, so you are less likely to hit usage limits. The challenge is that your users must be whitelisted and log in.

The Earth Engine App Engine examples directory on GitHub contains a set of useful App Engine examples. See the Example Apps page for a brief description of each example. This doc provides instructions for how to set up and deploy the examples or custom apps you create.

Deploying App Engine apps with Earth Engine

The following instructions explain how to deploy the demo apps on Mac OS and Linux. If you're on Windows, try this.

1. Create your own project

Each App Engine app needs its own project. To deploy your own instance, you'll need to create a new project with a unique ID (e.g. foo-ee-project).

To create an App Engine project for your app:

  1. Open the Google Developers Console.
  2. From the Select a project drop down menu in the upper right of the Developers Console, click Create a project....
  3. Enter a project name and click edit to choose a project ID.
  4. Click Create.

Once you've selected a project ID, update your app.yaml file. For example, the first line might be:

application: foo-ee-project
      

2. Set up credentials

Service account

A service account is used to authorize requests to Earth Engine on behalf of whomever is using your app. The config.py file contains authentication code using the service account email address and a private key file. To set up authentication with a service account:

  1. Create and authorize a service account.
  2. Download a P12 private key from the Google Developers Console. From the menu in the upper left of the Developers Console, choose Permissions > Service accounts. Click the menu for one of the service accounts and choose Create key. Select P12 and click Create to download the p12 key file.
  3. Convert the private key of that service account to PEM format:
    openssl pkcs12 -in downloaded-privatekey.p12 -nodes -nocerts > privatekey.pem
              
    If you are prompted for a password, use notasecret.
  4. Copy privatekey.pem into the directory that contains app.yaml.
  5. Update config.py (or an equivalent file in your source code) with your service account email address. (The path to the pem key file should not change since it's in your project directory).

OAuth 2.0 Client ID

If you want users to authenticate as themselves (rather than using a service account), you need to set up an OAuth Client ID. To do that:

  1. From the menu in the upper left of the Developers Console, choose API Manager > Credentials. Click Create credentials > OAuth client ID and select Web application.
  2. In the configuration of the web application, specify authorized JavaScript origins, for example:
    http://localhost:8080
    https://foo-ee-project.appspot.com
            
  3. Specify authorized redirect URIs, for example:
    http://localhost:8080/oauth2callback
    https://foo-ee-project.appspot.com/oauth2callback
            
  4. Update static/script.js (or an equivalent file in your source code) to use your client ID.
  5. Ensure ee_api_js.js is available in the /static/ directory (or equivalent). You can download it directly from GitHub or, if you've already cloned the entire EE API repo, copy it from earthengine-api/javascript/build on your local filesystem.

Check out the Google Identity OAuth documentation for a more detailed explanation of OAuth.

3. Set up the local development environment

Follow the instructions in each example directory on GitHub to download and build the project. If there's a build.sh file, run it from your application root folder with the command:

. ./build.sh
      

The setup script will download dependencies and install Google command line tools, if they don't already exist on your system. The Earth Engine Python API and its dependencies will be copied to a ./lib folder in your project directory.

Verify that the App Engine command line tools are available by running:

dev_appserver.py
      

If the command is not found, try manually downloading and installing the Google App Engine SDK for Python. If the command is available, it should fail with "error: too few arguments".

Also verify that the crypto library is installed with:

python -c "from oauth2client import crypt"
      

If an error is returned, install pyCrypto into your local Python distribution. For example, using pip:

sudo pip install pyCrypto
      

4. Run locally

Once your service account is whitelisted for Earth Engine access, you can use it to authenticate (see config.py) when you test the examples. Try testing the examples locally first by going into your project directory and running:

dev_appserver.py ./
      

Point your browser to http://localhost:8080 to see the app running on a local server. Any changes you make (and save) will be automatically picked up when you refresh the page.

Send feedback about...

Google Earth Engine API