A practical example of Google Earth Engine for Imagery Download

John R. Ballesteros
4 min readOct 24, 2023

--

What an incredible solution would be to have a tool for downloading fresh and past imagery of any part of the Earth, especially for different variables like: temperature, rain, NDVI, evapotranspiration, and many more. That is exactly what Google Earth Engine (GEE) is.

This story presents an example of how to download imagery of a specific area of interest (AOI), using a polygon shapefile format (*.shp) or its compressed version (.zip).

First of all open GEE in this link:

Upload the AOI stored in a local disk of your computer, by clicking on the assets button, and then, clicking the new button, see figures 1 and 2.

Figure 1. Upload data
Figure 2. Upload a shapefile

Navigate and choose your file and then click on upload, figure 3.

Figure 3

See the “Tasks” button in the right part of the application’s pane, it shows the status of the uploading task. Figure 4.

Figure 4. Tasks pane

Click on “Assets” again and verify that the file has been uploaded successfully, see figure 5.

Figure 5.

By clicking on the file you can see the details, location, and geometry. Figure 6.

Figure 6.

Downloading a rain imagery from CHIRPS Satellite

To be able to do this, we need to run a script whether in Java Script or Python.

// Import AOI Shapefile
var geometry = ee.FeatureCollection("projects/ee-jballes/assets/Gasoducto_Buffer");

// Select dates for CHIRPS satellite imagery
var chirps = ee.ImageCollection('UCSB-CHG/CHIRPS/DAILY')
.filterDate('2022-09-01', '2022-12-01');
print(chirps);

// Maximum values of precipitation are needed since they are more critical
var precipitation_chirps = chirps.max().clip(geometry);

// Defining the color palette
var visParams = {
min:0, // min val
max: 100, // max val
palette: 'red, white, blue' // colors of the raster
}

// Visualize results on a map
Map.centerObject(geometry); // center results on the map
Map.addLayer(precipitation_chirps, visParams, 'Precipitation_CHIRPS'); // create a raster layer

// Export tiff to Gdrive
Export.image.toDrive({
image: precipitation_chirps, // tiff name
description: 'precipitation_chirps', // description
folder: 'Rasters_GEE', // folder name
region: geometry, // AOI
scale: 3, // GSD, spatial resolution in meters (3m)
crs: 'EPSG:3116', // coordinate system (CRS)
maxPixels: 1e13 // Max number of pixeles to export
});

// If resultant raster contains to many pixels, the results would be
// exported in more than one files

To run the script, open the “Scripts” tab and paste the code, Figure 7.

Figure 7. Scripts Panel
Figure 8.

Go ahead an hit “Run”, after that, the results are saved into GDrive. Figure 9.

Figure 9.

The results can be merged into only one raster, see Figure 10.

Figure 10.

Conclusion

This story presents a brief description and code on how to query and download precipitation imagery of a specific region of our planet. It can be extended to any variable and place, also Python programming language can be used. Results in .Tif format can be stored in Google Drive and later be used in QGIS or ArcGIS.

Support me

Enjoying my work? Show your support with Buy me a coffee, a simple way for you to encourage me and others to write. If you feel like it, just click the next link and I will enjoy a cup of coffee!

--

--

John R. Ballesteros

Ph.D Informatics, Assoc. Professor of the UN, Med. Colombia. GenAi, Consultant & Researcher AI & GIS, Serial Interpreneur Navione Drone Services Co, Gisco Maps