Google Earth Engine - thomaspingel/advanced_remote_sensing GitHub Wiki
Both Google Earth Engine (GEE) and Microsoft's Planetary Computer are two ways to process very large sets of geospatial data on the web. GEE is often used in the Remote Sensing community, and supports both JavaScript and Python-based coding.
Google Earth Engine is a way to process large amounts of remote sensing data in the cloud. Rather than downloading layers and processing them locally, researchers write code that lets them pull information out of these layers, visualize them as maps and charts, and download processed datasets. For instance, a researcher might be interested in examining how NDVI has changed over the eastern United States over a period of 40 years. Such data would be arduous to assemble from conventional datasets. GEE, however, lets you access the query and aggregate the data in a matter of minutes.
One of our favorite examples of GEE in the literature is Sofia Ermida’s calculation of temperature from Landsat-8 data (Ermida et al., 2020). You can view her code at https://code.earthengine.google.com/?accept_repo=users/sofiaermida/landsat_smw_lst.
While most applications of GEE seem to be in JavaScript, coding in Python is supported as well. Qiusheng Wu's geemap project is a good example of this. Tyler Erickson has a number of resources to support Jupyter/Python coding in GEE as well.
Quick Links
- The Earth Engine Code Editor - the primary Earth Engine development environment.
- The Earth Engine Developer docs including:
- The Earth Engine Explorer - a graphical user interface. No programming skills needed.
Getting Started
- Sign up for a GEE account at earthengine.google.com/signup. signup is free and access is granted instantaneously via email.
- You will then be able to code your work at code.earthengine.google.com.
- Open g.co/earth/g4g18-ee101-repo. This will add some excellent examples to your repository to learn from. It is the repo mentioned in the next tutorial video. You can click on any script at left and load it. Then, hit "run" to execute the script.
- Watch tutorials videos from Google Earth, Parts 1 and 2.
- Follow along with the tutorials at developers.google.com/earth-engine/tutorials/tutorial_api_01.
Additional Tutorials
- GEE Tutorial
- Qiusheng Wu's geemap for Python and GEE
- Spatial Thoughts GEE Tutorial
- Terrain modeling using Google Earth Engine
- Least Cost Path Mapping
- Cloud-Based Remote Sensing with Google Earth Engine: Fundamentals and Applications is a good resource to learn GEE basics and get acquainted with various applications
Using Shapefiles for Clipping
- Users can upload shapefiles in google earth engine code editor to clip areas. In the assets section of the code editor, you can click on new, select shapefiles and browse to the folder where the shapefile is. Remember, along with the *.shp file, you have to upload other associated files as well
- The shapefile will have a directory address within the code editor. Use that address, and write the following code to define the area of interest.
var roi = ee.FeatureCollection('shapefile directory');
Code Sample
The following is a simple example to access SRTM elevation data, calculate slope from it, and visualize these plus a water layer:
var srtm = ee.Image("CGIAR/SRTM90_V4"),
water = ee.Image("JRC/GSW1_0/GlobalSurfaceWater");
var slope = ee.Terrain.slope(srtm);
Map.addLayer(srtm, {min:0, max:3000}, 'srtm');
Map.addLayer(slope, {min:0, max:45, palette:'green,yellow,red'}, 'slope');
Map.addLayer(water, {bands:'occurrence', min:25, max:75, palette:'lightblue,blue'}, 'occurrence');
A more advanced example
Shashank Karki prepared code to access Landsat data, calculate surface temperature using Sofia Ermida's method, crop by region, specify years of interest, and download data to Google Drive. The repository is at https://code.earthengine.google.com/?accept_repo=users/shashankkarki/NDVI_LST, and the code is copied here:
/*
Author: Shashank Karki
Using this code and any data derived with it,
you agree to cite the following reference
in any publications derived from them:
Ermida, S.L., Soares, P., Mantas, V., Göttsche, F.-M., Trigo, I.F., 2020.
Google Earth Engine open-source code for Land Surface Temperature estimation from the Landsat series.
Remote Sensing, 12 (9), 1471; https://doi.org/10.3390/rs12091471
*/
//Land Surface tempereature calculation based on Landsat_LST.js file (Ermida, Soares, Mantas, Göttsche & Trigo, 2020)
var LandsatLST = require('users/sofiaermida/landsat_smw_lst:modules/Landsat_LST.js')
var dataset = ee.FeatureCollection('TIGER/2016/States');
// Select region of interest (State Name)
var state='Georgia'
var va = ee.Feature(dataset.filter(ee.Filter.eq('NAME', state)).first());
var geometry=va.geometry();
Map.centerObject(geometry);
//Return the list of starting date and ending date
function range(start, end) {
var lst = [];
for (var i=start; i<=end; i++) {
lst.push(i);
}
return lst;
}
//Select the study period (Starting year, Ending year) the ouput will include both the starting year and ending year
var years = range(1985,1990);
print (years)
//Function returns the list of starting year, ending year and the satellite image to be used
function date(year_arr) {
var empty = [];
for(var i=0; i<year_arr.length; i++){
var st = year_arr[i]+"-"+"01"+"-"+"01";
var en = year_arr[i]+"-"+"12"+"-"+"28";
//Assign the landsat satellite to be used based on year input
if (parseInt(year_arr[i])>=2014) {
var landsatCol = 'L8';
}
else if (parseInt(year_arr[i])>=2012) {
landsatCol = 'L7';
}
else {
landsatCol = 'L5';
}
empty.push([st,en,landsatCol])
}
return empty
}
var annualMap = date(years)
var use_ndvi = true;
//Map annual data over study period
var img = function(dates,i) {
// get landsat collection with added variables: NDVI, FVC, TPW, EM, LST
var LandsatColl = LandsatLST.collection(dates[2], dates[0], dates[1], geometry, use_ndvi);
// Average of Image Collection over the year
var exImage = LandsatColl.median().set('year',dates[0]);
//Visualization Pallettes
var cmap1 = ['blue', 'cyan', 'green', 'yellow', 'red'];
var cmap2 = ['F2F2F2','EFC2B3','ECB176','E9BD3A','E6E600','63C600','00A600'];
Map.centerObject(geometry)
Map.addLayer(exImage.select('NDVI'),{min: -1, max: 1, palette: ['blue', 'white', 'green']}, 'NDVI');
Map.addLayer(exImage.select('LST'),{min:270, max:320, palette:cmap1}, 'LST');
//Export NDVI and LST to your Google Drive Folder
var desp_ndvi = ee.String('NDVI-').cat(String(years[i])).cat("-").cat(state);
desp_ndvi.evaluate(function (d){
Export.image.toDrive({
image: exImage.select('NDVI'),
description: d,
maxPixels: 4e10,
scale: 30,
region: geometry,
fileFormat: 'GeoTIFF',
});
});
var desp_LST = ee.String('LST-').cat(String(years[i])).cat("-").cat(state);
desp_LST.evaluate(function (d){
Export.image.toDrive({
image: exImage.select('LST'),
description: d,
maxPixels: 4e10,
scale: 30,
region: geometry,
fileFormat: 'GeoTIFF',
});
});
};
annualMap.map(img);
References
- Ermida et al. 2020. Google Earth Engine open-source code for Land Surface Temperature estimation from the Landsat series.
- Wu et al. 2019. Integrating LiDAR data and multi-temporal aerial imagery to map wetland inundation dynamics using Google Earth Engine.
- Wu, Q. 2020. geemap: A Python package for interactive mapping with Google Earth Engine