ii. Make a single point geometry with the geometry drawing tools and position the
point in a location of interest. (How about an annual grassland or a deciduous
forest?) Name the import roi.
b. Filtering, masking and preparing bands of interest
i. preprocess the Landsat imagery by filtering it to the location of interest, masking
clouds, and adding the variables in the model:
// This field contains UNIX time in milliseconds.
var timeField = 'system:time_start';
// Function to cloud mask from the pixel_qa band of Landsat 8 SR data.
// (From the Code Editor Examples > Cloud Masking)
function maskL8sr(image) {
// Bits 3 and 5 are cloud shadow and cloud, respectively.
var cloudShadowBitMask = 1 << 3;
var cloudsBitMask = 1 << 5;
// Get the pixel QA band.
var qa = image.select('pixel_qa');
// Both flags should be set to zero, indicating clear conditions.
var mask = qa.bitwiseAnd(cloudShadowBitMask).eq(0)
.and(qa.bitwiseAnd(cloudsBitMask).eq(0));
// Return the masked image, scaled to reflectance, without the QA
bands.
return image.updateMask(mask).divide(10000)
.select('B[0-9]*')
.copyProperties(image, ['system:time_start']);
}
// Use this function to add variables for NDVI, time and a constant
// to Landsat 8 imagery.
var addVariables = function(image) {
// Compute time in fractional years since the epoch.
var date = ee.Date(image.get(timeField));
var years = date.difference(ee.Date('1970-01-01'), 'year');
// Return the image with the added bands.
return image
// Add an NDVI band.
.addBands(image.normalizedDifference(['B5', 'B4']).rename('NDVI'))
// Add a time band.
.addBands(ee.Image(years).rename('t'))
.float()
// Add a constant band.
评论0
最新资源