Exploring Google Earth Engine Code Editor (To Build Pretty Landsat Map)

Catharina Kartika Utami
4 min readApr 2, 2024

--

You can teach yourself Google Earth Engine in one afternoon!

I am currently doing mini research for a course, and we’re looking at the development case of Golden Triangle SEZ in Lao PDR. I was just starting to get curious about what happened in the area due to the high coverage of illegal trade activities. I also want to understand what’s going on in Special Economic Zones in Mekong Countries, some of which are only a few hours flights away from my hometown in Jakarta.

While my research is still in work, I want to share a tool I learned to create an exciting map that can help build my argument in the final deliverables (more on that coming soon, I hope). For this, I have been interested in using Landsat Satellite Imagery but felt that somehow, USGS’ EarthExplorer is not really user-friendly. I tried browsing through some alternatives and found that I could retrieve the Landsat satellite images and download them from Google Earth Engine.

Then I thought, “Sounds easy enough.” But the problem is that I don’t know how to use this tool. Silly me, as usual.

The Google Earth Engine code editor is in JavaScript (which I’m not really familiar with), and we have to enter via Google Cloud Project that gave us some free quotas for us to try the technology (check here for more info). So, on a Tuesday afternoon during last spring break, I sat for a couple of hours trying to familiarize myself with the tools. I got so much help from watching Ramadhan — ‘s tutorial on YouTube (super big thanks for sharing!) and practically just played around with the environment.

This is how the code editor looks like:

Below is the setup process where I determine which datasets I’ll be retrieving the images from. You don’t really need to type these codes; you can actually do these steps by interacting with the interface to drop points and draw the image extent with their tool (upper left on the map area). For the datasets, you can retrieve them by typing the title in the search bar and clicking import.

var poi = /* color: #d63000 */ee.Geometry.Point([100.10658647877892, 20.351417117869662]),
extent =
/* color: #ffc82d */
/* displayProperties: [
{
"type": "rectangle"
}
] */
ee.Geometry.Polygon(
[[[100.03882611413363, 20.37861247006639],
[100.03882611413363, 20.292819654328646],
[100.2077409090555, 20.292819654328646],
[100.2077409090555, 20.37861247006639]]], null, false),

/*below is where you'll add the Landsat you need; since I am trying
to explore data from from the year 2000-2023, I need to use both Landsat 5
(available for data March 1984–May 2012) and Landsat 8 (available April 2013–Present)

You can explore available datasets in Google Earth Engine here:
https://developers.google.com/earth-engine/datasets/
*/

l5 = ee.ImageCollection("LANDSAT/LT05/C02/T1_TOA"),
l8 = ee.ImageCollection("LANDSAT/LC08/C02/T1_TOA");

In the next step, we can start writing in the code editor, choosing which dataset we want to work on first, determining the date filter to get the data we want, and applying the cloud filter to get a clearer image. We can also specify the bands we use to render the image (Red, Green, Blue).

var gtsez = l8.filterDate('2023-01-01', '2023-12-31').filter(ee.Filter.lte('CLOUD_COVER',40)).filterBounds(poi).first();
Map.addLayer(gtsez,{bands:['B4','B3','B2'], min:0,max:0.3},'gtsez');

It will give you something like the picture above. Now, you’ll check the clarity of the image and see if you need to adjust the cloud filter value or if you need to lengthen the date filter to get a clearer picture.

In the last step, we’re going to export thefile with all the bands. Here, we would basically determine the name of the file and the folder where we will save the file in our Google Drive.

var exportgtsez = gtsez.select(['B1','B2','B3','B4','B5','B6','B7','B8','B9','B10','B11']);
Export.image.toDrive({
image:exportgtsez,
description:'file_name',
folder:'folder_name',
region:extent,
scale:30
});

In the end, I finally managed to download the .tiff files for the Landsat images I needed, then proceeded to create a pretty gif showing the land clearing and development activity in the Golden Triangle SEZ with a bit of bands combination change done in QGIS.

We’re not gonna get more technical here (since I’m still figuring out if I am doing all of these the right way HAHA). I just want to close this by sharing that free resources are available everywhere and that Youtube videos really can help a lot with our work. So kudos to all the creators sharing their knowledge in the internet!

References:

This is the video created by Ramadhan that helped me learn Google Earth Engine: https://www.youtube.com/watch?v=v5tOke64unc&list=PLqJomOJYeNaawXFnDxR_3nM4Ue9Q0AsL9&index=1

Landsat 8 Collection 2 Tier 1 TOA Reflectance and Landsat 5 TM Collection 2 Tier 1 TOA Reflectance images courtesy of the U.S. Geological Survey.

--

--