-
Notifications
You must be signed in to change notification settings - Fork 8
/
mannKendall.js
41 lines (31 loc) · 1.72 KB
/
mannKendall.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
/*
This script uses MODIS 1km NDVI product and analyzes the long term trend of
NDVI by Mann-Kendal's test.The tau value ranges from -1 to 1. Positive
values (green) indicate an increase in the trend while negative values
suggest the trend of decreasing of vegetation.
Note: unfortunately the p-value is disabled for the moment by Google,
therefore, the result could only be used for an indication of the trend.
Contact: Shunan Feng (冯树楠): fsn.1995@gmail.com
*/
//------------------------------------------------------------------------//
// Preparation //
//------------------------------------------------------------------------//
// study time range
var year_start = 2001; // MODIS NDVI 2000-02-18T00:00:00 - Present
var year_end = 2018;
var month_start = 1;
var month_end = 12;
var date_start = ee.Date.fromYMD(year_start, 1, 1);
var date_end = ee.Date.fromYMD(year_end, 12, 31);
// The defalt setting will correlate 2 month time scale of SPEI(SPEI2m)
// with one month lag of three month sum of NDVI anomalies.
//------------------------------------------------------------------------//
// Datainput //
//------------------------------------------------------------------------//
// load MODIS NDVI 2000-02-18T00:00:00 - Present
var ndvi = ee.ImageCollection('MODIS/006/MOD13A2')
.filterDate(date_start, date_end)
.select('NDVI');
var ndviTrend = ndvi.reduce(ee.Reducer.kendallsCorrelation());
var corrParams = {min: -1, max: 1, palette: ['red', 'white', 'green']};
Map.addLayer(ndviTrend.select('NDVI_tau'), corrParams, 'Mann-Kendall test');