-
Notifications
You must be signed in to change notification settings - Fork 1
/
rindes
105 lines (90 loc) · 3.04 KB
/
rindes
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
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
/**** Start of imports. If edited, may not auto-convert in the playground. ****/
var geometry = /* color: #d63000 */ee.FeatureCollection(
[ee.Feature(
ee.Geometry.Polygon(
[[[-59.002365002264774, -37.26971948939343],
[-59.007343182196415, -37.265894395383306],
[-59.01841534100989, -37.26917305928853],
[-59.026311764349735, -37.27648123375289],
[-59.02013195477942, -37.2811936055169]]]),
{
"system:index": "0"
}),
ee.Feature(
ee.Geometry.Polygon(
[[[-59.00103462659339, -37.26330082209913],
[-58.99468315564612, -37.26835554343563],
[-58.98198021375159, -37.26002190252021],
[-58.988331684698856, -37.25605968424254]]]),
{
"system:index": "1"
})]);
/***** End of imports. If edited, may not auto-convert in the playground. *****/
var cloudBitMask = ee.Number(2).pow(10).int();
var cirrusBitMask = ee.Number(2).pow(11).int();
var to = new Date();
var since = new Date(to -1000 * 60 * 60 * 24 * 150);
var S2Collection = ee.ImageCollection('COPERNICUS/S2').filterBounds(geometry).filterDate(since, to).filterMetadata('CLOUDY_PIXEL_PERCENTAGE','less_than',2);
var S2CloudMasked = S2Collection
.map(function (image) {
var qa = image.select('QA60');
var mask = qa.bitwiseAnd(cloudBitMask).eq(0)
.and(qa.bitwiseAnd(cirrusBitMask).eq(0));
return image.updateMask(mask);
});
/*
Rinde Maiz = 22,068*NDVI^2-9,5584*NDVI+2,6075
Rinde Girasol= -3454,1*NDVI^2+10145*NDVI-3663,2
*/
var NDVI = S2Collection
.map(function (image) {
return image.addBands(image.normalizedDifference(['B8', 'B4']).rename('NDVI'));
})
.select(['NDVI'])
.map(function (image) {
var rinde = image.expression(
'-3454.1 * ( NDVI ** 2 ) + 10145 * NDVI - 3663.2',
{
'NDVI':image.select('NDVI')
}
);
return image.addBands(rinde.rename('RINDE_GL'));
})
.map(function (image) {
var rinde = image.expression(
'22.068 * ( NDVI ** 2 ) - 9.5584 * NDVI + 2.6075',
{
'NDVI':image.select('NDVI')
}
);
return image.addBands(rinde.rename('RINDE_MZ'));
});
var chart_opt = { title: 'NDVI',hAxis: {title: 'Tiempo'},vAxis: {title: 'NDVI'} };
print(ui.Chart.image.series(NDVI.select(['NDVI']), geometry).setOptions(chart_opt));
var reduced = NDVI.map(function(image){
return image.reduceRegions({
collection:geometry ,
reducer:ee.Reducer.mean(),
scale: 30
});
});
print(reduced);
var table = reduced.flatten();
print(table);
//print('NDVI max:', NDVI.aggregate_max('NDVI'));
/*
var rinde = ee.Number.expression(
'22.068 * ( NDVI ** 2 ) - 9.5584 * NDVI + 2.6075',
{
'NDVI': 0.80
}
);
print(rinde);
var rinde = ee.Number.expression(
'( -3454.1 * ( NDVI ** 2 ) + 10145 * NDVI - 3663.2 ) / 1000',
{
'NDVI': 0.80
}
);
print(rinde);
*/