Earth Engine Code Editor  |  Google Earth Engine  |  Google for Developers (2024)

The Earth Engine (EE) Code Editor atcode.earthengine.google.com is aweb-based IDE for the Earth Engine JavaScript API. Code Editor features aredesigned to make developing complex geospatial workflows fast and easy. The CodeEditor has the following elements (illustrated in Figure 1):

  • JavaScript code editor
  • Map display for visualizing geospatial datasets
  • API reference documentation (Docs tab)
  • Git-based Script Manager (Scripts tab)
  • Console output (Console tab)
  • Task Manager (Tasks tab) to handle long-running queries
  • Interactive map query (Inspector tab)
  • Search of the data archive or saved scripts
  • Geometry drawing tools

Earth Engine Code Editor | Google Earth Engine | Google for Developers (1)

Figure 1. Diagram of components of the Earth Engine Code Editor atcode.earthengine.google.com.

The Code Editor has a variety of features to help you take advantage of theEarth Engine API. View example scripts or save your own scripts on theScripts tab. Query objects placed on the map with the Inspector tab.Display and chart numeric results using the Google Visualization API.Share a unique URL to your script with collaborators and friends with theGet Link button. Scripts you develop in the Code Editor are sent to Googlefor processing and the generated map tiles and/or messages are sent back fordisplay in the Map and/or Console tab. All you need to run the CodeEditor is a web browser (use Google Chrome forbest results) and an internet connection. The following sections describeelements of the Earth Engine Code Editor in more detail.

JavaScript editor

The JavaScript editor will:

  • Format and highlight code as you type
  • Underline code with problems, offer fixes and other hints for correct syntax
  • Autocomplete pairs of quotes, brackets and parentheses
  • Offer code completion hints for Earth Engine functions

Above the code editor are buttons for running the script, saving the script,resetting the output map and console, and getting a link to the script. When theGet Link button is pressed, a unique link will appear in the browser'saddress bar. This link represents the code in the editor at the time the buttonwas pressed.

API reference (Docs tab)

On the left side of the Code Editor is the Docs tab, which contains thecomplete JavaScript API documentation. The documentation can be searched andbrowsed from the Docs tab.

Script Manager (Scripts tab)

The Scripts tab is next to the API Docs in the left panel of the CodeEditor. The Script Manager stores private, shared and example scripts inGit repositories hosted by Google. The repositories arearranged by access level, with your private scripts stored in a repository youown in the Owner folder: users/username/default. You (and only you) haveaccess to the repositories in the Owner folder unless you share them withsomeone else. The repositories in the Writer folder are repositories forwhich write access has been granted to you by their owner. You can add newscripts to, modify existing scripts in, or change access to (you may not removetheir owner) the repositories in the Writer folder. The repositories in theReader folder are repositories for which read access has been granted to youby their owner. The Examples folder is a special repository managed byGoogle which contains code samples. The Archive folder contains legacyrepositories to which you have access but have not yet been migrated by theirowner from an older version of the Script Manager. Search through your scriptsusing the filter bar at the top of the Scripts tab.

Earth Engine Code Editor | Google Earth Engine | Google for Developers (2)

Figure 2. The Script Manager.

Click the Earth Engine Code Editor | Google Earth Engine | Google for Developers (3) button tocreate a new repository in the Owner folder or to create folders and fileswithin a repository. You can rename scripts with the edit icon and delete them with the deleteicon. You can move scripts and organize them into folders using drag and drop(Figure 2). If you drag a script to another repository, it gets copied.

All scripts and repositories maintain full version history. Click on thehistory icon next to a script or repository to compare orrevert it to an older version. To delete a repository, click thedelete icon. To configure access to a repository, click thesettings icon next to the repository name. Note that if youshare a repository, the person with whom you're sharing will need to accept therepository by clicking the link shown in the settings dialog. Previouslyaccepted repositories can be hidden by clicking the blockicon following the repo name in the Script Manager.

Repositories can be accessed using Git, so you can manageand edit your scripts outside the Code Editor, or sync them with an externalsystem like GitHub. (Learn more about Git from thistutorial). Click on the settingsicon next to the repository name for instructions on cloning the repository.Note that you can browse the repositories to which you have access by going toearthengine.googlesource.com. For someGit operations, you may need to create authentication credentials by going tothe "Generate Password" link at the top of theearthengine.googlesource.com page.

Script modules

It's good practice to write modular, reusable code that can be shared betweenscripts without extensive copying and pasting. To enable modular development,Earth Engine provides the ability to share code between scripts. For example,suppose you write a function that performs a usefulset of operations. Rather than copy the code of the function into a new script,it's easier for the new script to load the function directly. To make a functionor object available to other scripts, you add it to a special object calledexports. To use the code in another script, use the require function to loadthe exports from another script. For example, suppose you define the followingmodule in a file named FooModule.js which is in a folder named Modules:

Code Editor (JavaScript)

/** * The Foo module is a demonstration of script modules. * It contains a foo function that returns a greeting string. * It also contains a bar object representing the current date. * @module Modules/FooModule *//** * Returns a greeting string. * @param {ee.String} arg The name to which the greeting should be addressed * @return {ee.String} The complete greeting. */exports.foo = function(arg) { return 'Hello, ' + arg + '! And a good day to you!';};/** * An ee.Date object containing the time at which the object was created. */exports.bar = ee.Date(Date.now());

Note the use of the exports keyword in the form of exports.objectToExport.You can make use of this module in another script by using the requirefunction. For example:

Code Editor (JavaScript)

var Foo = require('users/username/default:Modules/FooModule.js');print(Foo.doc);print(Foo.foo('world'));print('Time now:', Foo.bar);

The require function expects a string that describes the absolute path to thelocation of the module. Specifically, the argument of require() is of the form'pathToRepository:pathToModuleScript'. You can only load modules fromrepositories that you own and/or have read access to. If you want others to beable to use your module, the repository must be shared with the other users youwant to have access. You may wish to document your module to help othersunderstand how to use it; we recommend using JSDocstyle with the@module tag.

You can use the URL parameter ?scriptPath={repo}:{script} to share a referenceto a file in your repo, e.g.https://code.earthengine.google.com/?scriptPath=users/username/utils:utils.Upon visiting the URL, the referenced file and its repo will be added to eitherthe Reader or Writer directory on the Scriptstab, depending on your permission levelfor the shared repo.

Asset Manager (Assets tab)

The Asset Manager is in the Assets tab in the left panel. Use the AssetManager (Figure 3) to upload and manage your own image assets in Earth Engine.See the Asset Manager page for details.

Earth Engine Code Editor | Google Earth Engine | Google for Developers (4)

Figure 3. The Asset Manager.

Script links

Code Editor scripts can be shared via an encoded URL. The following sectionsdescribe various ways to generate a script URL, available options, and methodsfor managing script URLs.

Get link

The "Get Link" button at the top of the Code Editor (Figure 4) provides aninterface for generating script URLs and setting script behavior options. Notethe distinctions between snapshot and saved script URLs described below.

Earth Engine Code Editor | Google Earth Engine | Google for Developers (5)

Figure 4. The "Get Link" button.

Snapshot script links

Code in the Editor can be shared via an encoded snapshot URL that gets createdupon clicking the "Get Link" button at the top of the Code Editor. When the URLis visited by someone with an Earth Engine account, the browser will navigate tothe Code Editor and replicate the environment as it was when the link wascreated, including code, imports, map layers, and map position. Clicking the"Get Link" button will automatically copy the script link to the clipboard.Additionally, a dialog box will appear providing options to control theexecution of the shared script, along with buttons to copy and visit thegenerated link. The control options include preventing the script fromautomatically running, and hiding the code pane when someone opens the sharedlink. The draggable dialog box can be dismissed via the "Esc" key or a clickelsewhere on the page.

Saved script links

Saved scripts have an option to share a link that will always load the mostrecent saved version and is only accessible by you and others with currentaccess to the repository containing the script. To use this feature, load asaved script from the Script Manager tab, click the dropdown arrow to the rightof the "Get Link" button and select "Copy Script Path". A dialog box will appearpresenting the shareable script URL. Note that the script URL has also been setin the browser's address bar. For guidance on sharing your repository withothers, please see the Script Managersection.

Script link management

The dropdown button to the right of the "Get Link" button has an option to"Manage Links". Clicking this option loads a new browser tab with an interfacefor you to recall, remove, and download previously generated script links.Selecting a script and pressing the download button will download a zippedfolder ("code_editor_links.zip") to your system containing a .txt filerepresentation for each selected script.

Script link URL parameters

The ui.url module allows programmatic manipulation of the script URL'sfragment identifier via get and set methods. This means that Code Editorscripts and Earth Engine Apps can read and store values in the page's URL.Notice the end of the following two URLs, the first sets the debug variable asfalse and the second sets it as true; visit both links and notice that thedebug checkbox in the console is not checked in the first, and is checked in thesecond, changing the behavior of each script.

https://code.earthengine.google.com/5695887aad76979388a723a85339fbf2#debug=false;
https://code.earthengine.google.com/5695887aad76979388a723a85339fbf2#debug=true;

This feature can be used to set map zoom and center, as well as other behaviorsyou might want to customize when sending links to particular people or groups.

To find datasets to use in your scripts, you can use the search tool for thedata archive. The search tool is the text box at the top of the Code Editor thatsays 'Search places and datasets...' Type the name of a data product, sensor, orother keyword into the search bar and click the searchbutton to see a list of matching places, raster and table datasets. Click on anyraster or table result to see the description for that dataset in the archive.To import the dataset directly into your script, click the import link orthe Earth Engine Code Editor | Google Earth Engine | Google for Developers (6) button from thedataset description.

Imports

The results of importing datasets to your script are organized in an importssection at the top of your script, hidden until you import something. Once youhave created some imports, you should see something similar to Figure 5. To copyimports to another script, or convert the imports to JavaScript, click thesubject icon next to the Imports header and copy thegenerated code into your script. You can delete the import with thedeleteicon.

Earth Engine Code Editor | Google Earth Engine | Google for Developers (7)

Figure 5. The imports section at the top of the Code Editor.

Map

The Map object in the API refers to the map display in the Code Editor. Forexample, Map.getBounds() will return the geographic region visible in the CodeEditor. Check the Map functions in the API to see other customizations forthis display.

Layer Manager

Use the Layer Manager in the upper right corner of the map to adjust the displayof layers you added to the map. Specifically, you can toggle the visibility of alayer or adjust its transparency with the slider. Click thesettingsicon to adjust visualization parameters for individual layers. The visualizationtool that appears (Figure 6) allows you to interactively configure layer displayparameters. Click the button on the right of the tool (which performs aCustom stretch to the supplied min and max range by default) to linearlystretch the display to either percentiles or standard deviations of image valuesin the display window. Statistics are computed from all the pixels in the Mapwindow at the current zoom level. Use the sliders to adjust gamma and/ortransparency. Click the Palette radio button and specify a custom palette byadding colors (add), removing colors (remove) or manually entering a comma separatedlist of hex strings (edit) Click Applyto apply the visualization parameters to the current display. Click Importto load a visualization parameters object as a new variable in the importssection of your script.

Earth Engine Code Editor | Google Earth Engine | Google for Developers (8)

Figure 6. The layer visualization tool.

Inspector tab

The Inspector tab next to the Task Manager lets you interactively query themap. When the Inspector tab is activated, the cursor becomes a crosshairwhich will display the location and layer values under the cursor when you clickon the map. For example, Figure 7 shows the results of clicking on the mapwithin the Inspector tab. The cursor location and zoom level are displayedalong with pixel values and a list of objects on the map. The objects list isinteractive. To see more information, expand the objects in the Inspectortab.

Earth Engine Code Editor | Google Earth Engine | Google for Developers (9)

Figure 7. The Inspector tab shows information about the cursor location andthe layer values under the cursor.

Console Tab

When you print() something from your script, such as text, objects or charts,the result will be displayed in the Console. The console is interactive, soyou can expand printed objects to get more details about them.

Tasks tab

Earth Engine Tasks are operations that are capable of running much longer thanthe standard API request timeout. These long-running tasks are the onlymechanism for creating persistent artifacts in Earth Engine and adjacent systems(Google Cloud Storage, Google Drive, etc.), and they fall into two categories:Import and Export.

Import tasks can be used to uploadimages orupload tablesinto Earth Engine from a variety of filetypes (.csv, .tif, etc.). Exporttasks can be used to execute and write results from the EE computation system(see the guide for exportingdata ).

For exports, each call to an Export function in the Code Editor will populatean entry in the Unsubmitted tasks section of the Tasks tab. To submit anexport task to the server, click the Run button next to the task. Aconfiguration dialog will appear that allows you to specify a variety ofparameters for the task. If the task is fully specified at creation time (thatis, the call to Export has all necessary parameters), hold ctrl or whileclicking Run to submit the task without showing the dialog.

For imports, file upload happens locally before the task is submitted to theserver. Import tasks in the upload phase will show their progress in theUnsubmitted tasks section and automatically submit to the server once thefile upload is complete.

Unsubmitted tasks only appear on the page which created them, and they are lostwhen the page is closed. Once a task is submitted to the server, clicking on itsrow in the UI will provide additional information and options about the taskstatus, including the option to request cancellation.

To view, search and cancel many tasks in a full-page view (including on mobileclients), use the Task Manager.

Profiler

The profiler displays information about the resources (CPU time, memory)consumed by specific algorithms and other parts of a computation. This helps todiagnose why a script is running slowly or failing due to memory limits. To usethe profiler, click the Run with profiler option in the dropdown on the Runbutton. As a shortcut, hold down Alt (or Option on Mac) and click Run, or pressCtrl+Alt+Enter. This activates a Profiler tab on the right side of the codeeditor. As the script runs, the Profiler tab will display a table ofresource usage from the script. Clicking the Run button (without profiling)will make the Profiler tab disappear and disable the profiler.

See the computation overview page for abreakdown of the profiler's output.

You can also import geometries to your script by drawing them on screen. Tocreate geometries, use the geometry drawing tools in the upper left corner ofthe map display (Figure 8). For drawing points, use the placemark iconEarth Engine Code Editor | Google Earth Engine | Google for Developers (10), fordrawing lines, use the line iconEarth Engine Code Editor | Google Earth Engine | Google for Developers (11), for drawingpolygons, use the polygon iconEarth Engine Code Editor | Google Earth Engine | Google for Developers (12), fordrawing rectangles use the rectangle iconEarth Engine Code Editor | Google Earth Engine | Google for Developers (13). (Notethat rectangles are planar geometries, so they cannot be placed on a layer withgeodesic geometries like lines and polygons.)

Using any of the drawing tools will automatically create a new geometry layerand add an import for that layer to the Imports section. To add geometries to anew layer, hover on the Geometry Imports in the map display and click the +newlayer link. You can also toggle visibility of the geometries from the GeometryImports section. Note that drawn geometries are geodesic by default, except forrectangles, which are planar only. Use the Geometryconstructor to convert them to planargeometries. Learn more about geometries in Earth Engine on the Geometrypage.

Earth Engine Code Editor | Google Earth Engine | Google for Developers (14)

Figure 8. The geometry drawing tools are in the upper left corner of themap display.

To configure the way geometries are imported to your script, click thesettings icon next to the layer in the Geometry Importssection on the map or in the Imports section of the code editor. Thegeometry layer settings tool will be displayed in a dialog box which should looksomething like Figure 9. Note that you can import the drawn shapes asgeometries, features or feature collections. The geometry import settings alsoallow you to change the color with which the layer is displayed, add propertiesto the layer (if it is imported as a Feature or FeatureCollection) or renamethe layer.

Earth Engine Code Editor | Google Earth Engine | Google for Developers (15)

Figure 9. The geometry configuration tool.

Finally, to prevent geometries in a layer from being edited, you can lock thelayer by pressing the lock_open icon next tothe layer. This will prevent adding, deleting, or editing any geometries on thelayer. To unlock the layer again, press the lockicon.

Help!

Click thehelp button in the upper right of the Code Editor to see links to this Developer's Guide, other help forums, aguided tour of the Code Editor and a list of keyboard shortcuts that help withcoding, running code, and displaying data on the Map. Click thefeedbackbutton to file a bug report, request a new feature, suggest a dataset, orotherwise send feedback when no response is needed.

Earth Engine Code Editor  |  Google Earth Engine  |  Google for Developers (2024)

FAQs

Earth Engine Code Editor  |  Google Earth Engine  |  Google for Developers? ›

The Earth Engine

Earth Engine
Google Earth Engine is a cloud-based geospatial analysis platform that enables users to visualize and analyze satellite images of our planet. Scientists and non-profits use Earth Engine for remote sensing research, predicting disease outbreaks, natural resource management, and more.
https://www.google.com › earth › tools › google-earth-engine
(EE) Code Editor at code.earthengine.google.com is a web-based IDE for the Earth Engine JavaScript API. Code Editor features are designed to make developing complex geospatial workflows fast and easy. The Code Editor has the following elements (illustrated in Figure 1): JavaScript code editor.

What is the earth engine for developers? ›

With Earth Engine, you can perform geospatial processing at scale, powered by Google Cloud Platform. The purpose of Earth Engine is to: Provide an interactive platform for geospatial algorithm development at scale. Enable high-impact, data-driven science.

Is Google Earth Engine API free? ›

Earth Engine is free to non-commercial educational, research, and nonprofit use. Various remote sensing datasets are available in Earth Engine, including imagery, elevation data, classifications, atmospheric data, and even demographic data. Vector datasets are also accessible.

How to get Google Earth engine? ›

To use Earth Engine, you need access either via a Google Cloud project that's registered to use Earth Engine or via an individually signed-up account.

How to run code in Google Earth Engine? ›

Google Earth Engine Code Editor (IDE) Earth Engine can be used straight from your web browser via the Earth Engine Code Editor. This allows for much quicker data processing and the ability to immediately visualize your data. Once you've received the confirmation email, open up the Code Editor in your browser.

What can I do with Google Earth Engine? ›

Google Earth Engine is a cloud-based geospatial analysis platform that enables users to visualize and analyze satellite images of our planet. Scientists and non-profits use Earth Engine for remote sensing research, predicting disease outbreaks, natural resource management, and more.

What coding language is Google Earth Engine? ›

The Earth Engine API is available in Python and JavaScript, making it easy to harness the power of Google's cloud for your own geospatial analysis.

Is Google Developer API free? ›

All use of Google Search Console API is free of charge. However, it is subject to usage limits. Was this helpful? Except as otherwise noted, the content of this page is licensed under the Creative Commons Attribution 4.0 License, and code samples are licensed under the Apache 2.0 License.

What are the disadvantages of Google Earth Engine? ›

This blog will highlight some of the GEE's limitations and disadvantages. Importantly, Google Earth Engine is free only for non-commercial, non-production use, This means its sole purpose is to serve educational professionals, students, and nonprofit organizations mainly focusing on prototyping.

Is Google Earth Engine a GIS software? ›

Getting Started

Google Earth Pro is a free software that, albeit not a true GIS, allows visualization, assessment, overlay, and creation of geospatial data.

What is the difference between Google Earth Engine and Google Earth? ›

How is Earth Engine different from Google Earth? Google Earth enables you to travel, explore, and learn about the world by interacting with a virtual globe. You can view satellite imagery, maps, terrain, 3D buildings, and much more. Earth Engine, on the other hand, is a tool for analyzing geospatial information.

How much does Google Earth Engine cost? ›

On-demand pricing for Google Earth Engine compute (data processing) is $1.33 per Online Earth Engine Compute Unit (EECU) hour, $0.40 per Batch EECU-hour, and $0.026 per GB for the storage of that data.

Does Google Earth cost? ›

Google Earth Pro is free to use.

Does Google have a Code Editor? ›

Code view is the display mode that lets you view and edit your code in Google Web Designer's built-in code editor.

What is the new Code Editor by Google? ›

The new code editor is based on Eclipse Orion, and is part of Google Cloud Shell, a command line interface to manage GCP resources. You can access Cloud Shell via the browser from any computer with an internet connection, and it comes with the Cloud SDK and other essential tools pre-installed.

Is Google Earth Engine Python or JavaScript? ›

JavaScript is a good choice for working with GEE's web-based interface and for easy prototyping and visualisation of data. Still, Python is more suitable for scientific computing, data analysis and geospatial analysis tasks. While both languages can be used with GEE, each has pros and cons.

What is the earth engine? ›

Google Earth Engine is a computing platform that allows users to run geospatial analysis on Google's infrastructure. There are several ways to interact with the platform. The Code Editor is a web-based IDE for writing and running scripts.

What is considered to be the Earth's engine? ›

Mantle convection is the “engine” that drives our dynamic Earth. But since scientists cannot directly observe the workings of this engine, they have debated the exact mechanisms of this convection for more than half a century.

What are the advantages of Earth Engine? ›

  • It solves the hectic and time-consuming remote sensing processing, which means it solves our infrastructure problems.
  • It promotes a free multi-petabyte catalog of satellite imagery and geospatial datasets with planetary-scale analysis capabilities. However, the free version has some processing and storage limits.
Feb 20, 2024

Top Articles
Latest Posts
Article information

Author: Errol Quitzon

Last Updated:

Views: 6083

Rating: 4.9 / 5 (59 voted)

Reviews: 82% of readers found this page helpful

Author information

Name: Errol Quitzon

Birthday: 1993-04-02

Address: 70604 Haley Lane, Port Weldonside, TN 99233-0942

Phone: +9665282866296

Job: Product Retail Agent

Hobby: Computer programming, Horseback riding, Hooping, Dance, Ice skating, Backpacking, Rafting

Introduction: My name is Errol Quitzon, I am a fair, cute, fancy, clean, attractive, sparkling, kind person who loves writing and wants to share my knowledge and understanding with you.