Gee Api1
Gee Api1
(IRGN 490)
Ran Goldblatt
Lecture 9:
Google Earth Engine API-1
Images and Image Collections
https://code.earthengine.google.com/
• Includes a library of functions that can be applied to imagery for display and
analysis.
• Vector datasets (feature collections) are used via Google Fusion Tables.
3
2 1
5
4
https://code.earthengine.google.com/
1- Code editor | 2- Archive panel, documentation, examples | 3- Report panel, debugging and output
4- Display screen | 5- Draw feature geometries
Advanced GIS and Remote Sensing | Winter 2017 |
Ran Goldblatt
Advanced GIS and Remote Sensing | Winter 2017 |
Ran Goldblatt
Advanced GIS and Remote Sensing | Winter 2017 |
Ran Goldblatt
Advanced GIS and Remote Sensing | Winter 2017 |
Ran Goldblatt
Let`s begin…
JavaScript statements
• JavaScript statements have a pair of parentheses ()
• They end with a semicolon ;
• Anything between single quotes is called a 'string'.
• Strings:
• Used to print out readable information.
• Define sets of characters that name datasets or parts of datasets
print('hello class'); Advanced GIS and Remote Sensing | Winter 2017 |
Ran Goldblatt
Image and Image collection = Rasters
Images
• Pixels with associated values.
• An image can have multiple bands
• Each band in an image contains:
• A name
• Pixel value
• Resolution
• Projection
• Collections/
Mosaics of EE images
• Example:
• A collection of all L8 images
in a given time period
• Each image collection has
an ID.
print(landsat8TOA);
ee.ImageCollection('LANDSAT/LC8_L1T_8DAY_TOA')
Band 1 - blue
Band 2 - green
Band 3 - red
Band 4 - Near Infrared
Band 5 - Short-wave Infrared
Band 6 - Thermal Infrared
Band 7 - Short-wave Infrared
One band: value 0 is rendered as black and value 255 as white, with a linear gray
gradient in between.
0 255
green B2 green
red B3 blue
B4
Advanced GIS and Remote Sensing | Winter 2017 |
B5 Ran Goldblatt
The Map.addLayer() function can take a second parameter {} which describes
how the image should be visualized.
Map.addLayer(ee.Image('LANDSAT/LE7_TOA_1YEAR/2014'),
{}
);
Map.addLayer(ee.Image('LANDSAT/LE7_TOA_1YEAR/2014'), R G B
{'bands': ['B3', 'B2', 'B1']} L7 B3 B2 B1
); Advanced GIS and Remote Sensing | Winter 2017 | L8 B4 B3 B2
Ran Goldblatt
Selecting specific band(s) in an Image
.select('band name')
Map.addLayer(ee.Image('LANDSAT/LE7_TOA_1YEAR/2014')
.select('B3'));
var L7 = ee.Image('LANDSAT/LE7_TOA_1YEAR/2014');
var B3_L7 = L7.select('B3');
Map.addLayer(B3_L7);
Advanced GIS and Remote Sensing | Winter 2017 |
Ran Goldblatt
var L7 = ee.Image('LANDSAT/LE7_TOA_1YEAR/2014');
var B3_L7 = L7.select('B3');
Map.addLayer(B3_L7);
Task:
Filter an image collection only for scenes in a specific date
(second half of 2014) Advanced GIS and Remote Sensing | Winter 2017 |
Ran Goldblatt
Advanced GIS and Remote Sensing | Winter 2017 |
Ran Goldblatt
.filterDate()
ee.imageCollection.filterDate(date1, date2)
'2014-06-01', '2014-12-31'
'YYYY-MM-DD', 'YYYY-MM-DD'
Advanced GIS and Remote Sensing | Winter 2017 |
Ran Goldblatt
ee.ImageCollection('LANDSAT/LC8_L1T_32DAY_TOA')
.filterDate('2014-06-01', '2014-12-31');
var L8 = ee.ImageCollection('LANDSAT/LC8_L1T_32DAY_TOA');
var L8 = ee.ImageCollection('LANDSAT/LC8_L1T_32DAY_TOA');
• The default behavior is to select the most recent pixel- the one from the recent
scene in the stack.
Reminder:
Top of Atmosphere Reflectance (%)
Consider the angle and distance between
the sun, surface and satellite.
Advanced GIS and Remote Sensing | Winter 2017 |
Ran Goldblatt
ee.Algorithms.Landsat.simpleComposite(raw image collection)
We will:
• Add the collection
• Filter by date
• Find the maximum ndvi value
• Visualize it. Advanced GIS and Remote Sensing | Winter 2017 |
LANDSAT/LE7_L1T_32DAY_NDVI
Ran Goldblatt
var ndvi32Day= ee.ImageCollection('LANDSAT/LE7_L1T_32DAY_NDVI');
var filtered2000 = ndvi32Day
.filterDate('2014-01-01', '2014-12-31').max();
Map.addLayer(filtered2000);
https://code.earthengine.google.com/
print('hello class!');
var landsat8_32Days =
ee.ImageCollection('LANDSAT/LC8_L1T_32DAY_TOA');
Map.addLayer(landsat8_SecondHalf14,
{'bands': ['B4', 'B3', 'B2']}, 'landsat 8 at 2014');
var landsat8_32Days =
ee.ImageCollection('LANDSAT/LC8_L1T_32DAY_TOA');
Map.addLayer(landsat8_SecondHalf14,
{'bands': ['B4', 'B3', 'B2']}, 'landsat 8 at 2014');
Calculate the median value of this collection and add it to the map
var L8_32Days =
ee.ImageCollection('LANDSAT/LC8_L1T_32DAY_TOA');
Map.addLayer(filtered2014,
{'palette':'000000, 00FF00', 'min': 0.5, 'max': 0.7}, 'max ndvi 2014');
Map.addLayer(filtered2000,
{'palette':'000000, 00FF00', 'min': 0.5, 'max': 0.7}, 'max ndvi 2000');
Navigate to any region and present 2 Landsat images for the rainy season of
2013 and one for 2016, using the median value of the composite