Setting Python environment for GEE

 

Created on: 2/20/18
Last update: 2/20/18

Installing required packages

OpenSSL

On Ubuntu:

sudo apt-get install openssl

On Mac:

brew install openssl

Verify the installation:

openssl version

Setting GEE Python Environment

Create a new conda environment:

conda create --name py364_gee python=3.6.4
source activate py364_gee

Install dependencies:

conda install --name py364_gee pyCrypto pyOpenSSL

Install GEE:

pip install earthengine-api

Setting Up GEE Credentials

Authorize access to your Earth Engine account by running:

earthengine authenticate

An authentication code will be generated. Copy and paste it back to the terminal. If GEE is successfully authenticated, a message “Successfully saved authorization token.” will pop up.

The credentials is located at: ~/.config/earthengine/credentials

Verifying Installation

Running the following test code in Python panel:

# Import the Earth Engine Python Package
import ee

# Initialize the Earth Engine object, using the authentication credentials.
ee.Initialize()

# Print the information for an image asset.
image = ee.Image('srtm90_v4')
print(image.getInfo())

If everything is installed correctly, the metadata for an image should be printed:

{'type': 'Image', 'bands': [{'id': 'elevation', 'data_type': {'type': 'PixelType', 'precision': 'int', 'min': -32768, 'max': 32767}, 'dimensions': [432000, 144000], 'crs': 'EPSG:4326', 'crs_transform': [0.000833333333333, 0.0, -180.0, 0.0, -0.000833333333333, 60.0]}], 'version': 1494271934303000, 'id': 'srtm90_v4', 'properties': {'system:time_start': 950227200000, 'system:time_end': 951177600000, 'system:asset_size': 18827626666}}

Reference

Official

Python installation (manual)