26  Hands-on GEE (Aksara Lab)

NoteLecture & Discussion Session
  • Day / Date: Day 8 (Thursday, July 16, 2026)
  • Time: 13.00 - 15.00 WIB (GMT+7)
  • Presenter: Aksara Lab
  • Location: Teaching Lab, Faculty of Biology UGM

26.1 🎥 Recording Session

Recording Processing The session video will be available here soon.

26.2 📄 Lecture Slides

Open Slides in Google Drive

26.3 💻 Hands On Analysis with Google Earth Engine

Open GEE Training Script - Part 1 (Google Docs)

// GEE JavaScript Basics & Filtering (Part 1)

var kota = 'Yogyakarta';
var jumlahPenduduk = 78000000;
var luas = 150000;

print (kota);
print (jumlahPenduduk);
print (luas);

// List
var ibuKota = ['Jakarta', 'Jogja', 'Semarang', 'Surabaya'];
print(ibuKota);
print(ibuKota[2]);

// Dictionary
var dataKota = {
    'kota': kota,
    'populasi': jumlahPenduduk,
    'elevation': 930
  };
print(dataKota);

// Image
var JAXA = ee.Image ('JAXA/ALOS/AW3D30/V2_2');

var landsat = ee.Image('LANDSAT/LC08/C02/T1_TOA/LC08_044034_20140318');
var vizParamsLandsat = {
    bands: ['B5', 'B4', 'B3'],
    min: 0,
    max: 0.5,
    gamma: [0.95, 1.1, 1]
  };

var srtm = ee.Image("CGIAR/SRTM90_V4");
var elevation = srtm.select('elevation');

// Image Collection
var sentinel= ee.ImageCollection('COPERNICUS/S2_SR');

var landsat = ee.ImageCollection('LANDSAT/LC08/C02/T1_TOA')
    .filter(ee.Filter.eq('WRS_PATH', 44))
    .filter(ee.Filter.eq('WRS_ROW', 34))
    .filterDate('2014-03-01', '2014-08-01');
print('Collection: ', landsat);

// Feature Collection
var dataset = ee.FeatureCollection('FAO/GAUL/2015/level1');

var filtered = dataset.filter(ee.Filter.eq('ADM1_NAME', 'Kalimantan Barat'));
var geometry = filtered.geometry();

Map.centerObject(geometry);

var styleParams = {
  fillColor: 'b5ffb4',
  color: '00909F',
  width: 1.0,
};

dataset = dataset.style(styleParams);

Map.addLayer(filtered, {}, 'Kabupaten Kalimantan Barat');

var geometry = ee.Geometry.Point([110., -7.]);
Map.centerObject(geometry, 10);

var s2 = ee.ImageCollection('COPERNICUS/S2_HARMONIZED');

// Filter by metadata
var filtered = s2.filter(ee.Filter.lt('CLOUDY_PIXEL_PERCENTAGE', 30));

// Filter by date
var filtered = s2.filter(ee.Filter.date('2019-01-01', '2020-01-01'));

// Filter by location
var filtered = s2.filter(ee.Filter.bounds(geometry));

// Apply all three filters to the collection
var filtered1 = s2.filter(ee.Filter.lt('CLOUDY_PIXEL_PERCENTAGE', 30));
var filtered2 = filtered1.filter(
  ee.Filter.date('2019-01-01', '2020-01-01'));
var filtered3 = filtered2.filter(ee.Filter.bounds(geometry));

// Dot notation chaining
var filtered = s2.filter(ee.Filter.lt('CLOUDY_PIXEL_PERCENTAGE', 30))
  .filter(ee.Filter.date('2019-01-01', '2020-01-01'))
  .filter(ee.Filter.bounds(geometry));

print(filtered.size());

26.4 💻 GEE Training Script - Part 2

Open GEE Training Script - Part 2 (Google Docs)

// Image Reduction, Masking, and Exporting (Part 2)

// Load Landsat 8 OLI data for the region in 2022
var landsat8_collection = ee.ImageCollection('LANDSAT/LC08/C02/T2_TOA');

// Define the study area boundary
var landsat8_studyArea = landsat8_collection.filterBounds(geometry);

// Filter the image acquisition date
var landsat8_SA_2022 = landsat8_studyArea.filterDate('2022-01-01', '2022-12-31');
print(landsat8_SA_2022, 'landsat8_SA_2022');

// Reduce the image collection to obtain the median value for each pixel
var median_landsat8_2022 = landsat8_SA_2022.median();
print(median_landsat8_2022, 'median_landsat8_2022');

// Display the image
Map.addLayer(median_landsat8_2022,
{ min: 0.05, max: 0.8, bands: ['B6', 'B5', 'B4']});
Map.centerObject(geometry, 10);

// Load Landsat 8 OLI data for the Aceh region in 2023
var landsat8 = ee.ImageCollection("LANDSAT/LC08/C02/T2_TOA")
                .filterDate ('2023-01-01', '2023-12-31')
                .filterBounds(geometry)
                .median()
                .clip(geometry);

// Set visualization parameters for Landsat 8
var visualLandsat8 = {
    bands: ['B6', 'B5', 'B4'],
    min : 0,
    max : 1,
};

// Display the image on the map
Map.addLayer (landsat8, visualLandsat8, 'Landsat 8 Aceh');
Map.centerObject (geometry);

// Export the image to Google Drive
Export.image.toDrive({
    image: landsat8,
    description: 'Landsat 8 Aceh',
    folder: 'ee_demos',
    crs: 'EPSG:4326',
    region: geometry,
    scale:30,
    fileFormat: 'GeoTIFF',
    maxPixels: 1e13
  });

// Export the image to an Earth Engine Asset
Export.image.toAsset({
    image: landsat8,
    description: 'Landsat 8 Aceh',
    assetId: 'exampleExport',
    crs: 'EPSG:4326',
    region: geometry,
    scale:30,
    fileFormat: 'GeoTIFF',
    maxPixels: 1e13
  });

// Sentinel-2 cloud masking
var s2 = ee.ImageCollection("COPERNICUS/S2_SR_HARMONIZED");
var l8 = ee.ImageCollection("LANDSAT/LC08/C02/T1_L2");

function cloudMask(image){
    var scl = image.select('SCL');
    var mask = scl.eq(3).or(scl.gte(7).and(scl.lte(10)));
    return image.updateMask(mask.eq(0));
  }

var image = s2.filterBounds(geometry)
  .filterDate('2023-01-01', '2023-12-31')
  .map(cloudMask)
  .median()
  .clip(geometry);

Map.addLayer(image, {bands: ['B8', 'B4', 'B3'], min: 0, max: [5000, 3000, 2000]}, 'Sentinel-2');

// Landsat cloud masking
function cloudMaskLandsat(image){
  var qa = image.select('QA_PIXEL');
  var dilated = 1 << 1;
  var cirrus = 1 << 2;
  var cloud = 1 << 3;
  var shadow = 1 << 4;

  var mask = qa.bitwiseAnd(dilated).eq(0)
    .and(qa.bitwiseAnd(cirrus).eq(0))
    .and(qa.bitwiseAnd(cloud).eq(0))
    .and(qa.bitwiseAnd(shadow).eq(0));

  return image.updateMask(mask);
}

// Landsat
var landsat8 = l8.filterBounds(geometry)
  .filterDate('2023-01-01', '2023-12-31')
  .map(cloudMaskLandsat)
  .median()
  .multiply(0.0000275).add(-0.2)
  .clip(geometry);

Map.addLayer(landsat8, {bands: ['SR_B5', 'SR_B6', 'SR_B2'], min: 0, max: [0.5, 0.3, 0.2]}, 'Landsat');

// Load a Landsat 8 image.
var image = ee.Image('LANDSAT/LC08/C02/T1/LC08_044034_20140318');

// Combine the mean and standard deviation reducers.
var reducers = ee.Reducer.mean().combine({
  reducer2: ee.Reducer.stdDev(),
  sharedInputs: true
});

// Use the combined reducer to calculate the mean and standard deviation of the image.
var stats = image.reduceRegion({
  reducer: reducers,
  bestEffort: true,
});

// Display the dictionary containing the mean and standard deviation for each band.
print(stats);