Professional Documents
Culture Documents
Curso Gee 2019
Curso Gee 2019
Curso Gee 2019
Rafael Kayser
Fev/2019
Course content
Ambiente de
desenvolvimento on
Ferramenta que realiza a comunicação line
entre o usuário e o servidor da Google
(JavaScript API ou Python API) Introduction to Google Earth Engine
Tipos de API
> 200 public datasets > 4000 new images every day
> 5 million images > 5 petabytes of data
BAI
EVI 8-day
Derived NDVI 32-day
datasets NBRT annual
NDSI
NDWI
Introduction to Google Earth Engine
MODIS collection
https://developers.google.com/earth-
engine/datasets/catalog/modis Introduction to Google Earth Engine
Digital Elevation Models
• SRTM Version 3 (30m) - NASA / USGS / JPL-Caltech
• SRTM Version 4 (90m) – NASA/CGIAR
• Derived products from SRTM
• ALOS Global 30m
• HydroSHEDS products
• Conditioned DEM 3/15 arc-sec
• Void-Filed DEM 3/15 arc-sec
• Drainage Direction 3/15 arc-sec
• Flow Accumulation 3/15 arc-sec
Netherlands
• High resolution Australia
https://global-surface-water.appspot.com/
Derived products
https://earthenginepartners.appspot.com/science-2013-global-forest
Derived products
http://mapbiomas.org/
https://developers.google.com/earth-engine/datasets/
Types of platforms
• Code Editor
• code.earthengine.google.com
• Web-based IDE for Earth Engine API
• Explorer
• explorer.earthengine.google.com
• Simple web interface
• It allows anyone to visualize the data in the public data
catalog
• Signed in Earth Engine users can also import data, run
simple analyses, save, and export the results
• Client library
• provide JavaScript and Python wrapper functions for
the Earth Engine API
• Build custom applications and to develop Earth Engine
code locally using a JavaScript or Python interpreter
Explorer
https://explorer.earthengine.google.com
Referência
https://developers.google.com/earth-engine/
Code editor
Inserir
Display
geometria
https://code.earthengine.google.com/
Creating a new project
1
2
Repository: folder to
store projects
https://www.w3schools.com/jsref/jsref_obj_math.asp
Noções básicas de JavaScript
Lists (arrays)
Define lists with square brackets [ ]. A list of numbers or strings, for example:
print('Dictionary:', object);
// Access dictionary items using dot notation.
print('Print foo:', object.foo);
// Function example
var function_hello = function( name ) {
var message = 'Hi ' + name + '! How are you?';
return message;
};
var ans;
if (a>b){
ans = "a greater than b";
} else if (a<b){
ans = "b greater than a";
} else {
ans = "a equals b";
}
print(ans);
ee.String
ee.Number
ee.List
ee.Dictionary
var name = ee.Object(value) ee.Date
ee.Geometry
ee.Image
ee.ImageCollection
....
Image
ImageCollection
var name = ee. Geometry .( value)
Feature
FeatureCollection
ee.Algorithms()
ee.Array()
ee.Classifier()
ee.Filter()
ee.Join()
ee.Projection()
ee.Reducer()
ee.Terrain()
ee.Kernel()
....
ee.Geometry.Point is a Earth Engine API call that receives one parameter: ee.List ([])
// Area in km²
print('Area (km²): ', polygon.area().divide(1000 * 1000));
//perimeter in km
print('Perimeter (km): ', polygon.perimeter().divide(1000));
Feature is an object with a geometry property storing a Geometry object (or null)
and a properties property storing a dictionary of other properties.
// Create an ee.Geometry.
var polygon = ee.Geometry.Polygon([
[[-35, -10], [35, -10], [35, 10], [-35, 10], [-35, -10]]
]);
print(polyFeature);
Map.addLayer(polyFeature, {}, 'feature');
Working with vectorial data
Inserting vectorial data
• Code / map • Assets • Fusion Table
2 3
//display on map
Map.addLayer(south_america_basins, {}, 'South America Basins');
4. Buscar o Table ID
File > About this table
> Get ID
.area() .aggregate()
.buffer() .filter()
.centroid() .filterBounds()
.dissolve() .first()
ee.Feature() .distance() ee.FeatureCollection()
.map()
.perimeter() .merge()
.union() .sort()
... .reducetoImage()
...
https://developers.google.com/earth-engine/api_docs
//display on map
Map.addLayer(amazon_basin, {color: 'green'}, 'Amazon Basin');
Map.addLayer(la_plata_basin, {color: 'blue'}, 'La Plata Basin');
collection_name.map( function_name)
// apply buffer
var fc_selected_basin_buff = fc_selected_basin.map(function_buffer);
Image ImageCollection
Collection ImageCollection ID
Landsat 5 Surface Reflectance Tier 1 LANDSAT/LT05/C01/T1_SR
Landsat 5 TM Collection 1 Tier 1 TOA Reflectance LANDSAT/LT05/C01/T1_TOA
Landsat 5 TM Collection 1 Tier 1 Raw Scenes LANDSAT/LT05/C01/T1
Landsat 7 Surface Reflectance Tier 1 LANDSAT/LE07/C01/T1_SR
Landsat 7 Collection 1 Tier 1 TOA Reflectance LANDSAT/LE07/C01/T1_TOA
Landsat 7 Collection 1 Tier 1 Raw Scenes LANDSAT/LE07/C01/T1
Landsat 8 Surface Reflectance Tier 1 LANDSAT/LC08/C01/T1_SR
Landsat 8 Collection 1 Tier 1 TOA Reflectance LANDSAT/LC08/C01/T1_TOA
Landsat 8 Collection 1 Tier 1 Raw Scenes LANDSAT/LC08/C01/T1
1 − 2
ee.Image.normalizedDifference( [‘B1’, ‘B2’] ) =
1+ 2
.add()
.subtract()
.multiply() image.select(‘B1’).add( image.select(‘B2’).multiply(image.select(‘B3’)) )
.divide()
.pow()
ee.Image .sin()
.cos()
.tan()
.log()
.log10()
... Working with raster data
Mathematical operations with images
// Load Landsat 8 TOA Reflectance Collection, filter by date, bounds and cloud cover
var collection = ee.ImageCollection('LANDSAT/LC08/C01/T1_TOA')
.filterDate('2014-01-01', '2014-03-01')
.filterBounds(geometry)
.filterMetadata('CLOUD_COVER', 'less_than', 20);
//display on map
Map.addLayer(basic, {palette: ['Cyan',
'GreenYellow','LimeGreen','Yellow','Orange','Red','DarkRed']},
'Elevation');
collection_name.map( function_name)
Examples:
• Reduction over time
• Reduction over space
• Reduction over bands
mean()
var new_image= image.reduce(ee.Reducer. max() );
etc
mean()
var new_image= collection.select(‘band’).reduce(ee.Reducer. max() );
etc
ReduceRegion
var output = image.reduceRegion(reducer, geometry, scale, crs, crsTransform, bestEffort, maxPixels, tileScale)
dictionary ee.Reducer.median()
optionals
ee.Reducer.max()
ee.Reducer.min()
...
dictionary
optionals
ee.Reducer.median()
ee.Reducer.max()
ee.Reducer.min()
...
Example: extract maximum altitude from a region
//get RS shapefile
var RS = ee.FeatureCollection('users/rafaelkayser/UF').filter(ee.Filter.eq('UFD_NM', 'Rio Grande do
Sul'));
// print
print('Maximum altitude (meters):', max_alt);
Example: calculate a reservoir surface area
https://code.earthengine.google.com/49b1e64b31e238ddc4b7c21912086afd
Module V
Exporting data
Making charts
• Histogramas • Séries espectrais por região
.setChartType(...)
.setOptions(...)
print(chart)
Making charts
Export.image.toDrive({
image: image_name,
region: feature.geometry(),
description: “image_description”,
folder: “name_folder”,
scale: scale_value, //default: 1000 meters
maxPixels: 1e9 //default: 1e8
});
// define a feature collection from assets
var fc_south_america_basins = ee.FeatureCollection('users/rafaelkayser/South_America_Basins');
// apply buffer
var fc_selected_basin_buff = fc_selected_basin.map(function_buffer);
https://code.earthengine.google.com/3b1001f55f8965cf684946ba09578d4e
Export table with time series data
https://code.earthengine.google.com/78354473a72631e1534b6f78c4b97314
Module VI
Special topics in GEE
Special topics in GEE
https://www.usgs.gov/media/files/landsat-4-7-surface-
reflectance-code-ledaps-product-guide
Landsat 8 Surface Reflectance – pixel_qa band
https://www.usgs.gov/media/files/landsat-8-surface-
reflectance-code-lasrc-product-guide
Functions to cloud remotion in SR images
// Function to mask clouds in Landsat 5/7 SR imagery. // Function to mask clouds in Landsat 8 SR imagery.
var f_cloudMaskL457_SR = function(image) { var f_cloudMaskL8_SR = function(image) {
var quality = image.select('pixel_qa'); var quality = image.select('pixel_qa');
var c01 = quality.eq(66); //Clear, low confidence cloud var c01 = quality.eq(322); //Clear, low confidence cloud
var c02 = quality.eq(68); //water, low confidence var c02 = quality.eq(324); //water, low confidence cloud
cloud var c03 = quality.eq(1346); //Clear terrain, terrain occluded
var mask = c01.or(c02); var mask = c01.or(c02).or(c03);
return image.updateMask(mask); return image.updateMask(mask);
}; };
// Function to mask clouds in Landsat 5/7 SR imagery // Function to mask clouds in Landsat 8 SR imagery.
var f_cloudMaskL457_SR_v2 = function(image) { var f_cloudMaskL8_SR_v2 = function (image) {
var qa = image.select('pixel_qa'); // Bits 3 and 5 are cloud shadow and cloud, respectively.
// If the cloud bit (5) is set and the cloud confidence (7) var cloudShadowBitMask = (1 << 3);
// is high or the cloud shadow bit is set (3), then it's a var cloudsBitMask = (1 << 5);
bad pixel. // Get the pixel QA band.
var cloud = qa.bitwiseAnd(1 << 5) var qa = image.select('pixel_qa');
.and(qa.bitwiseAnd(1 << 7)) // Both flags should be set to zero, indicating clear conditions.
.or(qa.bitwiseAnd(1 << 3)); var mask = qa.bitwiseAnd(cloudShadowBitMask).eq(0).
// Remove edge pixels that don't occur in all bands and(qa.bitwiseAnd(cloudsBitMask).eq(0));
var mask2 = image.mask().reduce(ee.Reducer.min()); return image.updateMask(mask);
return };
image.updateMask(cloud.not()).updateMask(mask2);
};
Landsat 5/7 TOA – BQA band
https://landsat.usgs.gov/collectionqualityband
Landsat 8 TOA – BQA band
https://landsat.usgs.gov/collectionqualityband
Script to remove cloud pixels
https://code.earthengine.google.com/b18dd1539c6fed43113dd6221a9ce027
Special topics in GEE
https://code.earthengine.google.com/202d043bf4a7dcdf1fe012fd5c17a6d3
Special topics in GEE
https://developers.google.com/earth-engine/
Referências