English

Google Earth Engine Tutorial for Beginners: AOI, Sentinel-2, and NDVI

Google Earth Engine (GEE) is a cloud platform that stores petabytes of satellite imagery, such as Sentinel-2, Landsat, and MODIS, and processes it through short JavaScript or Python scripts.

Google Earth Engine Tutorial for Beginners: AOI, Sentinel-2, and NDVI
Contents
  1. Why use Google Earth Engine instead of desktop GIS?
  2. What does the Code Editor look like?
  3. How to define an Area of Interest (AOI)
  4. Method 1: draw a geometry on the map
  5. Method 2: upload a shapefile as an asset
  6. Method 3: create a custom AOI from Google Earth
  7. How to get a cloud-free Sentinel-2 image for the AOI
  8. From imagery to agricultural decisions
  9. How to calculate NDVI for the AOI
  10. How to export the result to Google Drive
  11. Frequently asked questions
  12. Is Google Earth Engine free?
  13. Which language does Google Earth Engine use?
  14. Why does the composite still show gaps or clouds?
  15. How much storage does an Earth Engine account provide for assets?
  16. Can a KML file be used directly as an AOI?
  17. References

Versi bahasa Indonesia: Tutorial Lengkap Google Earth Engine

Short answer: Google Earth Engine (GEE) is a cloud platform that stores petabytes of satellite imagery, such as Sentinel-2, Landsat, and MODIS, and processes it through short JavaScript or Python scripts. A beginner workflow has five steps: (1) register and open the Code Editor; (2) define an Area of Interest (AOI); (3) filter an image collection by place, date, and cloud cover; (4) build a clipped composite and an index such as NDVI; and (5) export the result to Google Drive. No local installation or expensive license is required for research and education.

The first encounter with Google Earth Engine happened in March 2020, when the COVID-19 pandemic forced most office activities in Indonesia to move home while food production could not stop. The practical question was simple: how can harvested area and crop growth phases be estimated without visiting the field? Earth Engine answered that question, and this tutorial summarizes the workflow that proved useful for a complete beginner in remote sensing.

Why use Google Earth Engine instead of desktop GIS?

Desktop GIS software such as ArcGIS remains powerful for cartography. However, Earth Engine offers three advantages for agricultural monitoring. Firstly, access is free for research, education, and nonprofit use once a Google account and a Google Cloud project are registered at earthengine.google.com; commercial use requires a paid plan. Secondly, the data catalog is already loaded: Sentinel-2, Landsat, MODIS, rainfall, elevation, and many other datasets are available without downloading a single file, and some collections are updated every few days. Thirdly, the analysis is fully customizable because every step is written as code.

The third advantage is also the main hurdle. A beginner rarely knows what to type. Consequently, the most efficient learning path is to observe, imitate, and modify scripts published in the official documentation, tutorials, and journal articles that share their source code, rather than writing everything from scratch.

AspectDesktop GIS (e.g., ArcGIS)Google Earth Engine
InstallationLocal software and licenseWeb browser only
Satellite dataDownloaded scene by sceneCatalog already in the cloud
Processing powerLimited by the local computerGoogle servers
WorkflowMenus and toolboxesScripts (JavaScript or Python)
Best forDetailed cartography and editingLarge areas, time series, indices

What does the Code Editor look like?

After registration, the Code Editor at code.earthengine.google.com is divided into three columns. The left panel works as a library: it holds saved scripts, the API documentation (Docs), and uploaded assets. The middle panel is where code is written and run. The right panel contains three tabs: Console for printed tables, charts, and messages; Inspector for reading pixel values (for example, NDVI) at a clicked point; and Tasks for monitoring uploads and exports. The map below the three panels displays every layer added by the script.

Google Earth Engine Code Editor showing the script library, code panel, and console panel
The three main panels of the Google Earth Engine Code Editor.

How to define an Area of Interest (AOI)

Every analysis needs an Area of Interest, namely the boundary that limits the imagery to the object of study. Three methods suit different needs.

Method 1: draw a geometry on the map

The fastest method is to click the geometry tools at the top left of the map, select a point, rectangle, or polygon, and draw directly on the map. The script then shows an import line such as var geometry, which can be used immediately to filter and clip imagery. This method is ideal for practice.

Geometry drawing tools located at the top left of the Google Earth Engine map
Geometry drawing tools in the map panel.

Method 2: upload a shapefile as an asset

For real projects, an AOI should come from an official boundary. In the original work, a rice field layer for one regency was clipped to a single district (Sidamanik, Simalungun, North Sumatra) in ArcGIS with the Clip tool and exported as a shapefile. Indonesian administrative and land-use boundaries can be obtained free of charge from the national base map portal (Rupa Bumi Indonesia) after creating an account.

A shapefile consists of several files (.shp, .shx, .dbf, .prj, and others). These files are compressed into one ZIP archive. In the Assets tab, select New, then Shape files, choose the ZIP, and click Upload. Progress appears in the Tasks tab; refresh the Assets tab only after the task finishes. Clicking the asset and selecting Import adds it to the script as a variable, usually named table.

Uploading a zipped shapefile as a new asset in Google Earth Engine
Uploading a shapefile through the Assets tab.

Method 3: create a custom AOI from Google Earth

Sometimes the required boundary does not exist in any official map, for example the outline of a specific plantation, a group of rice fields, or Lake Toba, which borders six regencies and would be difficult to assemble from administrative boundaries. A practical workaround uses three free tools: (1) draw a polygon in Google Earth and save it as KML through the Save Place As menu; (2) convert the KML into a shapefile with an online converter such as MyGeodata Cloud; and (3) extract the result, rename the files without spaces, and upload the .shp, .shx, and .dbf files together as a new asset in Earth Engine.

Custom polygon drawn around Lake Toba in Google Earth before export to KML
A custom polygon drawn in Google Earth.

How to get a cloud-free Sentinel-2 image for the AOI

Tropical regions such as Indonesia are frequently covered by clouds, so a single scene is rarely usable. The standard solution is to filter many scenes, mask cloudy pixels, and combine the remaining pixels into a median composite. The script below uses the Sentinel-2 surface reflectance collection together with the Cloud Score+ dataset, which is the cloud mask currently recommended in the Earth Engine documentation.

// 1. Area of Interest: an imported asset (FeatureCollection)
var aoi = table;

// 2. Sentinel-2 surface reflectance with Cloud Score+ mask
var csPlus = ee.ImageCollection('GOOGLE/CLOUD_SCORE_PLUS/V1/S2_HARMONIZED');
var s2 = ee.ImageCollection('COPERNICUS/S2_SR_HARMONIZED')
  .filterBounds(aoi)
  .filterDate('2024-01-01', '2024-03-31')
  .linkCollection(csPlus, ['cs_cdf'])
  .map(function (img) {
    return img.updateMask(img.select('cs_cdf').gte(0.6));
  });

// 3. Median composite clipped to the AOI
var composite = s2.median().clipToCollection(aoi);
Map.centerObject(aoi, 12);
Map.addLayer(composite, {bands: ['B4', 'B3', 'B2'], min: 0, max: 3000}, 'True color');

// 4. NDVI from the near-infrared (B8) and red (B4) bands
var ndvi = composite.normalizedDifference(['B8', 'B4']).rename('NDVI');
Map.addLayer(ndvi, {min: 0, max: 0.8, palette: ['brown', 'yellow', 'green']}, 'NDVI');

// 5. Export to Google Drive at 10 m resolution
Export.image.toDrive({
  image: ndvi,
  description: 'ndvi_aoi',
  region: aoi.geometry(),
  scale: 10,
  maxPixels: 1e13
});

Running the script adds two layers to the map and creates an export task. The export starts only after clicking Run in the Tasks tab. The threshold of 0.6 on cs_cdf balances cloud removal and data availability; a higher value removes more haze but leaves more gaps.

Satellite composite clipped to rice fields in Sidamanik district, Simalungun, North Sumatra
Example result clipped to rice fields in Sidamanik, North Sumatra.

From imagery to agricultural decisions

The Indonesian Ministry of Agriculture already provides rice growth-phase statistics derived from Sentinel imagery at the district level. However, a table of hectares without a map is difficult to verify with extension workers in the field. Earth Engine fills that gap because it produces both the area estimate and the map, down to village level when village boundaries and the baseline rice field layer are available. Thus, the same workflow can support growth-phase mapping, harvested area estimation, and land-use classification with training samples.

How to calculate NDVI for the AOI

Once a clean composite is available, the normalized difference vegetation index (NDVI) is the most common first product. NDVI compares near-infrared reflectance, which healthy leaves reflect strongly, with red reflectance, which chlorophyll absorbs. For Sentinel-2, the bands are B8 (near-infrared) and B4 (red), so NDVI = (B8 − B4) / (B8 + B4). Values close to 1 indicate dense green vegetation, values around 0.2 to 0.4 indicate sparse or stressed vegetation, and values near or below 0 indicate water, bare soil, or built-up land.

var ndvi = composite.normalizedDifference(['B8', 'B4']).rename('NDVI');
Map.addLayer(ndvi.clip(aoi), {min: 0, max: 0.9, palette: ['brown', 'yellow', 'green']}, 'NDVI');

var stats = ndvi.reduceRegion({
  reducer: ee.Reducer.mean(),
  geometry: aoi,
  scale: 10,
  maxPixels: 1e10
});
print('Mean NDVI of the AOI', stats);

The reduceRegion call returns one summary number for the whole AOI. Thus, the same script can monitor a single field or an entire district, provided the scale (10 m for Sentinel-2 visible and near-infrared bands) and the maxPixels limit are set appropriately.

A small scene illustrates the value of this number. An extension officer standing at the edge of a shallot field in the dry season can see that the western corner looks paler than the rest, yet cannot tell whether the difference is serious. The NDVI map shows the same corner at 0.35 while the rest of the field sits at 0.65. The officer now has a measurable signal, and the conversation with the farmer moves from impression to evidence: irrigation in that corner is checked first.

How to export the result to Google Drive

Export.image.toDrive({
  image: ndvi.clip(aoi),
  description: 'ndvi_aoi',
  folder: 'GEE_exports',
  region: aoi,
  scale: 10,
  crs: 'EPSG:4326',
  maxPixels: 1e10
});

The export appears in the Tasks tab and must be started manually by clicking Run. The resulting GeoTIFF opens in QGIS, ArcGIS, or Python (rasterio). Consequently, Earth Engine handles the heavy processing in the cloud, while desktop software is used only for final cartography and reporting.

Related guides on Catatan Budi: ACF and PACF for SARIMA, MICMAC analysis tutorial, Granger causality test.

Frequently asked questions

Is Google Earth Engine free?

Earth Engine is free for noncommercial purposes such as research, education, and nonprofit work after registering a Google Cloud project. Commercial users need a paid subscription.

Which language does Google Earth Engine use?

The Code Editor uses JavaScript. A Python API is also available and is commonly used in Jupyter notebooks or Google Colab.

Why does the composite still show gaps or clouds?

Gaps appear when every scene in the date range is cloudy at the same location. Extending the date range, lowering the Cloud Score+ threshold slightly, or adding Landsat imagery usually solves the problem.

How much storage does an Earth Engine account provide for assets?

Asset quotas depend on the Cloud project and have changed over time. The current quota is shown in the Assets tab; at the time of the original work in 2020, each account received about 10 GB.

Can a KML file be used directly as an AOI?

The reliable route is to convert the KML into a shapefile and upload the .shp, .shx, and .dbf files together, as described in Method 3.

References

  • Gorelick, N., Hancher, M., Dixon, M., Ilyushchenko, S., Thau, D., and Moore, R. (2017). Google Earth Engine: Planetary-scale geospatial analysis for everyone. Remote Sensing of Environment, 202, 18–27.
  • Google Earth Engine Developers Guide. developers.google.com/earth-engine.
  • Pasquarella, V. J., Brown, C. F., Czerwinski, W., and Rucklidge, W. J. (2023). Comprehensive quality assessment of optical satellite imagery using weakly supervised video learning. CVPR Workshops (Cloud Score+).

How to cite this article: Agung Budi Santoso (2026). Google Earth Engine Tutorial for Beginners: AOI, Sentinel-2, and NDVI. Catatan Budi. https://agungbudisantoso.com/en/google-earth-engine-tutorial/

Photo of Agung Budi Santoso

Written by

Agung Budi Santoso

Lecturer in Management & Agribusiness · Universitas Sumatera Utara

A lecturer and researcher who turns statistics, econometrics, and agribusiness research methods into practical, step-by-step notes for students and researchers.

Discussion

No comments yet. Have a question about this topic? Write it below and I will do my best to answer.

Leave a comment

Your email address will not be published.