The following describes examples in the Earth Engine demos directory on GitHub. The title of each example is a link to the source on GitHub. The examples are organized by how they authenticate with Earth Engine. To learn more about authentication options and how to deploy these applications, see the App Engine & Earth Engine Overview.
Authentication with service accounts
To get started, consider this example the 'hello world' of Earth Engine applications on
the App Engine platform. The app displays an interactive map with an Earth Engine Image
(SRTM elevation). Inspect the
config.py file, noting that it needs to be
modified with your project's service account credentials. The only Earth Engine specific
code is in
server.py (two lines!). Note that Earth Engine gets a mapid
for the image to be displayed on the the app's page, then passes this value to the
Jinja template used to render the page.
Same as the example above, using Node.js instead. The
server.js file loads
service account credentials from a
privatekey.json file, and gets a mapid for the
image to be displayed on the app's page. This value is passed to the
Handlebars template used to render the page.
This is a more complex example of using server authentication. It adds several polygons to the map, displaying details about the polygons when a user clicks them. It uses the Google Visualization API for charting, and a technique called AJAX to retrieve new data from the server without needing to refresh the page.
This example uses a Node.js Cloud Function for server authentication. With the Earth Engine API and TurfJS, the function creates GeoJSON for a hexbin visualization. The webpage is static (hosted in Cloud Storage), and displays the hexbin visualization on a map. Unlike other examples, this demo does not use App Engine.
Authentication with OAuth2
This example also uses the client authorization flow. It demonstrates using
ee.MapLayerOverlay to add Earth Engine data to the map with a callback
function to keep track how many tiles have been loaded. (All of the mapping functionality
in this demo can be done with mapids generated on the server, as is done in the
This example also uses the client authorization flow. The example demonstrates functionality to draw a polygon over the map, perform a reduce region with the polygon in Earth Engine, and display the polygon mean. (All of the mapping functionality in this demo can be done with mapids generated on the server, as is done in the server-auth demo).
This is a relatively complex example. It demonstrates the use of two authentication flows, one for Earth Engine using the application's credentials and one for Google Drive using the user's personal credentials. It allows the user to select a layer, draw a polygon and export the layer clipped by the polygon to Drive.