SDKs overview
Google Earth Engine provides Software Development Kits (SDKs) that allow developers to interact with its platform programmatically. These SDKs facilitate access to the Earth Engine Data Catalog, execution of geospatial computations, and management of assets. The primary languages supported by official SDKs are Python and JavaScript, enabling integration into various development workflows, from scripting and data science environments to web-based applications.
The Python client library is designed for data scientists and developers who prefer a scripting environment, offering integration with popular Python ecosystems for data analysis. The JavaScript client library is integral to the Earth Engine Code Editor, a web-based IDE that supports rapid prototyping and visualization of geospatial data. Both SDKs provide a consistent interface for accessing the extensive Earth Engine API, allowing users to leverage Google's cloud infrastructure for large-scale geospatial processing without managing the underlying compute resources themselves. The platform's capabilities are detailed in the Google Earth Engine developer guides.
Official SDKs by language
Google Earth Engine maintains official SDKs for Python and JavaScript, which are the recommended interfaces for interacting with the platform. These SDKs are actively developed and supported by Google, ensuring compatibility with the latest Earth Engine features and APIs. Each SDK is tailored to the conventions and ecosystems of its respective language, providing a native development experience.
| Language | Package Name | Install Command | Maturity |
|---|---|---|---|
| Python | earthengine-api |
pip install earthengine-api |
Stable |
| JavaScript | Integrated into Earth Engine Code Editor | N/A (web-based) | Stable |
The Earth Engine API documentation provides comprehensive details on the functions and classes available through these SDKs. For Python, the library is distributed via PyPI, the Python Package Index, allowing for standard installation practices. The JavaScript API is intrinsically linked to the Earth Engine Code Editor, where users can write and execute scripts directly in a web browser without explicit installation steps.
Installation
Installation procedures vary depending on the chosen SDK. The Python SDK requires a local Python environment, while the JavaScript SDK is used directly within the Google Earth Engine Code Editor.
Python SDK Installation
-
Prerequisites: Ensure you have Python 3.x installed on your system. It is recommended to use a virtual environment to manage dependencies.
python3 -m venv ee_env source ee_env/bin/activate -
Install the
earthengine-apipackage: Use pip, the Python package installer.pip install earthengine-api -
Authenticate Earth Engine: After installation, you need to authenticate your Earth Engine account. This step links your local environment to your Google account with Earth Engine access.
earthengine authenticateThis command will open a web browser for you to log in with your Google account and grant permissions. Upon successful authentication, a refresh token is stored locally, allowing subsequent API calls without re-authentication.
JavaScript SDK Usage
The JavaScript SDK does not require a local installation. It is natively integrated into the Google Earth Engine Code Editor. Developers access the API directly within this web-based environment. To begin, simply navigate to the Code Editor, log in with your Google account, and start writing scripts.
Quickstart example
This example demonstrates how to load a satellite image collection, filter it by date and location, and compute a median composite using the Python SDK. This process is fundamental for many geospatial analysis tasks within Earth Engine.
import ee
import ee.mapclient
# Initialize the Earth Engine API
ee.Initialize()
# Define a region of interest (e.g., San Francisco Bay Area)
# For a real application, you might load this from a KML, GeoJSON, etc.
san_francisco_bay = ee.Geometry.Rectangle([-122.5, 37.5, -122.0, 38.0])
# Load a Sentinel-2 image collection
sentinel_collection = ee.ImageCollection('COPERNICUS/S2_SR') \
.filterDate('2023-01-01', '2023-01-31') \
.filterBounds(san_francisco_bay)
# Compute the median pixel value for the collection
median_image = sentinel_collection.median()
# Define visualization parameters for natural color (B4, B3, B2 for Sentinel-2)
vis_params = {
'min': 0,
'max': 3000,
'bands': ['B4', 'B3', 'B2']
}
# Add the median image to the map (requires ee.mapclient for local visualization or a different mapping library)
# For use in a Jupyter Notebook or similar environment:
# ee.mapclient.addToMap(median_image, vis_params, 'Median Sentinel-2 Image')
# ee.mapclient.centerMap(-122.25, 37.75, 9)
# To get information about the image (e.g., projection, bands):
print('Median image projection:', median_image.projection().getInfo())
print('Median image band names:', median_image.bandNames().getInfo())
# Exporting the image (example - requires a Google Cloud Storage bucket)
# task = ee.batch.Export.image.toDrive(
# image=median_image,
# description='san_francisco_sentinel2_median',
# folder='ee_exports',
# fileNamePrefix='san_francisco_median',
# scale=10,
# region=san_francisco_bay.getInfo()['coordinates']
# )
# task.start()
# print('Export task started:', task.status().getInfo())
This Python script initializes the Earth Engine API, defines a region of interest, filters a Sentinel-2 image collection, and computes a median composite. It then defines visualization parameters and prints some image metadata. While ee.mapclient is useful for local visualization in environments like Jupyter notebooks, for web applications, you would typically export the results or integrate with a client-side mapping library like Leaflet or OpenLayers.
For JavaScript, a similar quickstart within the Code Editor would look like this:
// Define a region of interest (e.g., San Francisco Bay Area)
var sanFranciscoBay = ee.Geometry.Rectangle([-122.5, 37.5, -122.0, 38.0]);
// Load a Sentinel-2 image collection
var sentinelCollection = ee.ImageCollection('COPERNICUS/S2_SR')
.filterDate('2023-01-01', '2023-01-31')
.filterBounds(sanFranciscoBay);
// Compute the median pixel value for the collection
var medianImage = sentinelCollection.median();
// Define visualization parameters for natural color (B4, B3, B2 for Sentinel-2)
var visParams = {
min: 0,
max: 3000,
bands: ['B4', 'B3', 'B2']
};
// Center the map and add the median image layer
Map.centerObject(sanFranciscoBay, 9);
Map.addLayer(medianImage, visParams, 'Median Sentinel-2 Image');
// Print information about the image to the console
print('Median image projection:', medianImage.projection());
print('Median image band names:', medianImage.bandNames());
Community libraries
Beyond the official SDKs, the Google Earth Engine community has developed various libraries and tools that extend its functionality and integrate with other platforms. These community contributions often address specific use cases, provide higher-level abstractions, or facilitate integration with popular data science and GIS tools.
-
geemap(Python): A Python package for interactive geospatial analysis with Google Earth Engine, ipyleaflet, and folium. It enables users to visualize Earth Engine data interactively in Jupyter notebooks, export data, and perform complex analyses with a simplified interface.geemapintegrates with popular Python libraries likexarrayandpandas, enhancing data manipulation capabilities. More information can be found in the geemap documentation. -
r-earthengine(R): An unofficial R package that provides an interface to Google Earth Engine. While not officially supported by Google, it allows R users to leverage the Earth Engine API within their familiar R environment, bridging the gap for R-centric data scientists and researchers. -
Earth Engine Apps: The community also develops and shares web applications built on top of Earth Engine, often using the JavaScript API. These apps typically focus on specific analyses or visualizations, making Earth Engine accessible to a broader audience without requiring coding expertise. Examples are showcased in the Earth Engine Apps documentation.
-
Various GEE-related GitHub repositories: Numerous open-source projects on GitHub provide utility functions, examples, and specialized algorithms for Earth Engine. These range from specific data processing workflows to advanced machine learning integrations. Searching GitHub for 'Google Earth Engine' often yields a wide array of community-contributed codebases.
These community-driven efforts enrich the Earth Engine ecosystem, offering alternative interfaces and specialized tools that cater to diverse user needs and technical backgrounds. Users should note that community libraries may have varying levels of support and maintenance compared to official SDKs.