Wiki

Clone wiki

computing / gce

Working with Compute Engine Instances to connect with Earth Engine

Follow the method if you already have a service account. To know more about creating an Earth Engine service account read this section of the documentation.
TODO: Using compute engine with ordinary account.

Start with installing Earth Engine Python SDK in you local machine.

Open your terminal in local machine.
Go through the authorization process by typing gcloud auth login and follow along.

To know the list of the modules for each service use gcloud components list

For updating all the components run gcloud components update

For updating a specific component run gcloud components update component-name

To know your current project gcloud config list

You will need this information to create compute instance within specific project. Create your Compute Engine micro instance, add the appropriate scopes:

GS_SCOPE=https://www.googleapis.com/auth/devstorage.full_control    
EE_SCOPE=https://www.googleapis.com/auth/earthengine    
gcloud compute instances create earth-engine1 \  
--machine-type f1-micro --zone us-central1-a --scopes ${GS_SCOPE},${EE_SCOPE}
You can find other available machine types (instances) here

TODO: Set the OS and hard drive size for the instance

ssh into the instance you created (see the use of quote)
gcloud compute --project "YourProjectID" ssh --zone "us-central1-a" "my-instance"

Once you are in the compute engine instance, you can install the Earth Engine SDK:

sudo apt-get update  
sudo apt-get install libffi-dev libssl-dev python-dev python-pip   
sudo pip install cryptography google-api-python-client earthengine-api

If getting the error message '...could not find .egg-info directory in install record...' try
sudo pip install --upgrade setuptools pip

Following should easily authenticate to Earth Engine in your scripts:

import ee
from oauth2client.client import GoogleCredentials
ee.Initialize(GoogleCredentials.get_application_default())

Last line produces the error: ee.ee_exception.EEException: Please authorize access to your Earth Engine account by running

Now if I use earthengine authenticate it would use my ordinary google account not service account. Need to fix it.

Not working

To find your Service Account id:
gcloud compute instances describe earth-engine1 --zone us-central1-a

Not working probably because I'm using ordinary google account.

Random: To find out what version of Linux (distro) you are running, enter the following command at the shell prompt:
$cat /etc/*-release

To install R
sudo apt-get install r-base

To install byobu
sudo apt-get install byobu

Updated