Sitemap
Max Kleiner

Max Kleiner⁠

Max Kleiner's professional environment is in the areas of OOP, UML and coding - among other things as a trainer, developer and consultant.

Google Earth Engine API

4 min readSep 2, 2026

maXbox Starter Tutorial 194

Google Earth Engine combines a multi-petabyte catalog of satellite imagery and geospatial datasets with planetary-scale analysis capabilities. Scientists, researchers, and developers use Earth Engine to detect changes, map trends, and quantify differences on the Earth’s surface. Earth Engine is now available for commercial use, and remains free for academic and research use.

We take a short look at the following API:

GitHub — google/earthengine-api: Python and JavaScript bindings for calling the Earth Engine API. · GitHub

Python and JavaScript client libraries for calling the Google Earth Engine API.

Here’s an example screenshot and the corresponding Code Editor JavaScript code:

Python Code Example

First we have to install the Python Lib:

py -3.14 -m pip install earthengine-api
python 3 -m pip install earthengine-api
Press enter or click to view image in full size
PIP Protocol Flow

Then we open a project (used or new) with an existing google account:

Press enter or click to view image in full size
Authenticator to use the API

Earth Engine runs in Google Cloud and requires Cloud Projects for access and API management. All Earth Engine calls (whether from the code editor, client libraries, apps, or the REST API) are routed through a Cloud Project. This allows you to use the Cloud Console for access control, resource management, and usage monitoring. After that we got an access:

Press enter or click to view image in full size

Projects created during registration can be managed in the Google Cloud Console. You can enable or disable the Earth Engine API on the “Earth Engine API” page in the Cloud Console.

Press enter or click to view image in full size
Each Project has Enabler / Disabler

Clientlibraries (Python, JavaScript)

The ee.Initialize() function specifies a project for Earth Engine requests originating from the Python and JavaScript client libraries. There are several ways to configure the project specification. See the Authentication and Initialization page for more information.

Get Max Kleiner’s stories in your inbox

Join Medium for free to get updates from this writer.

This code can be automatised with Python4Delphi in maXbox:

function PyCode2GoogleEarthEngineAPI(my_project, aAPIKey: string): string; begin with TPythonEngine.Create(Nil) do begin try loadDLL; autofinalize:= false; ExecString('import io,sys'); execString('import ee'); execStr('ee.Authenticate()'); execstr('output = io.StringIO()') //for print out ExecStr('ee.Initialize(project="'+my_project+'")'+lf+ //'files = {"image": image_file_descriptor}'+lf+ //'headers= {"X-Api-Key":"'+aAPIKey+'"}'+lf+ 'print(ee.String("Hello from Earth Engine servers!").getInfo())'); println(stringreplace(evalstr('output.getvalue().strip()'), #10,#13#10,[rfReplaceAll, rfIgnoreCase])); //result:= ((EvalStr('r.json()'))); except raiseError; finally free; end; end; end;
function PyCode2GoogleEarthEngineAPI(my_project, aAPIKey: string): string;
begin
with TPythonEngine.Create(Nil) do begin
try
loadDLL;
autofinalize:= false;
ExecString('import io,sys');
execString('import ee');
execStr('ee.Authenticate()');
execstr('output = io.StringIO()') //for print out
ExecStr('ee.Initialize(project="'+my_project+'")'+lf+
//'files = {"image": image_file_descriptor}'+lf+
//'headers= {"X-Api-Key":"'+aAPIKey+'"}'+lf+
'print(ee.String("Hello from Earth Engine servers!").getInfo())');
println(stringreplace(evalstr('output.getvalue().strip()'),
#10,#13#10,[rfReplaceAll, rfIgnoreCase]));
//result:= ((EvalStr('r.json()')));
except
raiseError;
finally
free;
end;
end;
end;

https://sourceforge.net/projects/maxbox5/files/examples/1494_GoogleEarthEngine_API1_7.txt/download

If you want to associate Earth Engine calls from the command-line tool with a cloud project, use the -project parameter in your call to earthengine or set a default project with set_project.

The path to the credentials is stored in the GOOGLE_APPLICATION_CREDENTIALS environment variable. To authenticate and initialize Earth Engine using the credentials, see the snippet below.

import json import os from google.auth import identity_pool scopes = [ "https://www.googleapis.com/auth/cloud-platform", "https://www.googleapis.com/auth/earthengine", ] path = os.environ["GOOGLE_APPLICATION_CREDENTIALS"] info = json.load(open(path)) credentials = identity_pool.Credentials.from_info(info).with_scopes(scopes) ee.Initialize(credentials, project=credentials.project_number)
import json
import os

from google.auth import identity_pool

scopes = [
"https://www.googleapis.com/auth/cloud-platform",
"https://www.googleapis.com/auth/earthengine",
]
path = os.environ["GOOGLE_APPLICATION_CREDENTIALS"]
info = json.load(open(path))
credentials = identity_pool.Credentials.from_info(info).with_scopes(scopes)
ee.Initialize(credentials, project=credentials.project_number)

When no used project can be found or the enabler is blocked you got an exception:

Exception: EEException: Google Earth Engine API has not been used in project ivory-plane-457016-q2 before or it is disabled. 
Enable it by visiting https://console.developers.google.com/apis/api/earthengine.googleapis.com/overview?project=ivory-plane-457016-q2 then retry.
Exception: EEException: Google Earth Engine API has not 
been used in project ivory-plane-457016-q2 before or it is disabled.
Enable it by visiting https://console.developers.google.com/apis/api/earthengine.googleapis.com/overview?project=ivory-plane-457016-q2 then retry.

If you enabled this API recently, wait a few minutes for the action to propagate to our systems and hopefully retry.

Originally published at http://teetrains.wordpress.com on September 2, 2026.

--

--

Max Kleiner
Max Kleiner

Written by Max Kleiner⁠

Max Kleiner's professional environment is in the areas of OOP, UML and coding - among other things as a trainer, developer and consultant.