Advance Change Detection: Time Series Trend Analysis with Linear Regression.

Stephen Chege
Jan 24, 2022

--

Let us get started.

Adds a band containing image date as years since 2000.
function createTimeBand(img) {
var year = ee.Date(img.get('system:time_start')).get('year').subtract(2000);
return ee.Image(year).byte().addBands(img);
}
var collection = ee.ImageCollection("MODIS/006/MOD13A2")
.select('EVI')
.map(createTimeBand);
var linearFit = collection.select(['year', 'EVI'])
.reduce(ee.Reducer.linearFit());
// Compute a linear fit over the series of values at each pixel, visualizing
// the y-intercept in green, and positive/negative slopes as red/blue.
Map.addLayer(
collection.reduce(ee.Reducer.linearFit()),
{min: 0, max: [50.0, 1500, -50.0], bands: ['scale', 'offset', 'scale']},
'EVI trend');
Map.addLayer(collection.reduce(ee.Reducer.linearFit()), imageVisParam, 'EVI SLope')

Play around with the Layers.

--

--

Stephen Chege
Stephen Chege

Written by Stephen Chege

Providing Geospatial data science related content. schege47@gmail.com

No responses yet