Geographic Information Systems Asked by npopovic on December 10, 2020
I’m trying to chart out EVI for a single pixel(roi) over time.
Basically trying to do what this link does for NDVI and apply it to the EVI available from landsat 8 imagery, but have no clue how to do it.
Heres my code for NDVI.
var cliptocol = function(image){
return image.clip(table);
};
var table = ee.FeatureCollection("users/napopovicc/nikanotee")
// Import the Landsat 8 TOA image collection.
var l8 = ee.ImageCollection('LANDSAT/LC08/C01/T1_TOA');
// Map a function over the Landsat 8 TOA collection to add an NDVI band.
var withNDVI = l8.map(function(image) {
var ndvi = image.normalizedDifference(['B5', 'B4']).rename('NDVI');
return image.addBands(ndvi);
});
// Create a chart.
var chart = ui.Chart.image.series({
imageCollection: withNDVI.select('NDVI'),
region: roi,
reducer: ee.Reducer.first(),
scale: 30
}).setOptions({title: 'NDVI over time'});
var cloudlessNDVI = l8.map(function(image) {
// Get a cloud score in [0, 100].
var cloud = ee.Algorithms.Landsat.simpleCloudScore(image).select('cloud');
// Create a mask of cloudy pixels from an arbitrary threshold.
var mask = cloud.lte(10);
// Compute NDVI.
var ndvi = image.normalizedDifference(['B5', 'B4']).rename('NDVI');
// Return the masked image with an NDVI band.
return image.addBands(ndvi).updateMask(mask);
});
print(ui.Chart.image.series({
imageCollection: cloudlessNDVI.select('NDVI'),
region: roi,
reducer: ee.Reducer.first(),
scale: 30
}).setOptions({title: 'Cloud-masked NDVI over time'}));
This should do what you need it to. You need to adjust the ndvi function to compute EVI instead and then map that function over the collection. Check this link to see how to compute EVI using an expression in GEE.
// Made up ROI
var roi = ee.Geometry.Point([-114, 52])
Map.addLayer(roi)
Map.centerObject(roi, 12)
// Import the Landsat 8 TOA image collection.
var l8 = ee.ImageCollection('LANDSAT/LC08/C01/T1_TOA')
.filterDate('2013-01-01','2020-01-01')
.filterBounds(roi);
// Map a function over the Landsat 8 TOA collection to add an EVI band.
var withEVI = l8.map(function(image) {
var evi = image.expression(
'2.5 * ((NIR - RED) / (NIR + 6 * RED - 7.5 * BLUE + 1))', {
'NIR': image.select('B5'),
'RED': image.select('B4'),
'BLUE': image.select('B2')
}).rename('EVI');
return image.addBands(evi);
});
print(withEVI.first())
// Create a chart.
var chart = ui.Chart.image.series({
imageCollection: withEVI.select('EVI'),
region: roi,
reducer: ee.Reducer.first(),
scale: 30
}).setOptions({title: 'EVI over time'});
var cloudlessEVI = l8.map(function(image) {
// Get a cloud score in [0, 100].
var cloud = ee.Algorithms.Landsat.simpleCloudScore(image).select('cloud');
// Create a mask of cloudy pixels from an arbitrary threshold.
var mask = cloud.lte(10);
// Compute EVI.
var evi = image.expression(
'2.5 * ((NIR - RED) / (NIR + 6 * RED - 7.5 * BLUE + 1))', {
'NIR': image.select('B5'),
'RED': image.select('B4'),
'BLUE': image.select('B2')
}).rename('EVI');
// Return the masked image with an NDVI band.
return image.addBands(evi).updateMask(mask);
});
print(ui.Chart.image.series({
imageCollection: cloudlessEVI.select('EVI'),
region: roi,
reducer: ee.Reducer.first(),
scale: 30
}).setOptions({title: 'Cloud-masked EVI over time'}));
Correct answer by rpr_mt on December 10, 2020
Get help from others!
Recent Answers
Recent Questions
© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP