-
Notifications
You must be signed in to change notification settings - Fork 0
/
goes-fire-monitoring.js
179 lines (151 loc) · 3.6 KB
/
goes-fire-monitoring.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
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
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
var CONFIG = {
startDate: '2017-05-24',
mapInitZoom: 6,
mapInitLat: -60.708,
mapInitLon: -18.285
}
var DQFVis = {
min: 0,
max: 5,
palette: [
'red', // Good quality fire pixel
'olive', // Good quality fire free land
'cornsilk', // Opaque cloud
'darkslateblue', // off earth, or missing input data
'green', // Bad input data
'burlywood' // Algorithm failure
]
};
var chosenDate = ee.Date(CONFIG.startDate);
var collection = ee.ImageCollection('NOAA/GOES/16/FDCF')
.filterDate(CONFIG.startDate, Date.now());
var layerCreated = false;
var showPic = function () {
setDate();
var img = collection.filterDate(chosenDate, chosenDate.advance(1, 'days'))
.select("DQF")
.first();
if (layerCreated) {
Map.layers().get(0).setEeObject(img);
}
else {
Map.addLayer(collection.first().select("DQF"), DQFVis, 'DQF');
layerCreated = true;
}
};
function setYMD(range) {
resetHour();
resetMinute();
showPic();
}
function setHour(value) {
resetMinute();
showPic();
}
function setMinute(value) {
showPic();
}
function resetHour() {
hourSlider.setValue(0);
}
function resetMinute() {
minuteSlider.setValue(0);
}
function createColorLabel(text, color) {
var label = ui.Label({
value: text,
style: {
backgroundColor: color,
margin: '0px',
width: '100%',
height: "32px",
fontFamily: 'Arial'
},
});
return label;
}
function createCenteredLabel(text) {
var label = ui.Label({
value: text,
style: {
margin: 'auto',
fontFamily: "Arial"
},
});
return label
}
function setDate() {
var YMD = ee.List(dateSlider.getValue()).get(0);
var hour = hourSlider.getValue();
var minute = minuteSlider.getValue();
chosenDate = ee.Date(YMD);
chosenDate = chosenDate.advance(hour, 'hours')
chosenDate = chosenDate.advance(minute, 'minutes')
}
var dateSlider = ui.DateSlider({
start: CONFIG.startDate,
period: 1,
onChange: setYMD
});
var hourSlider = ui.Slider({
min: 0,
max: 23,
value: 0,
step: 1,
onChange: setHour,
style: {
width: "120%"
}
});
var minuteSlider = ui.Slider({
min: 0,
max: 45,
value: 0,
step: 15,
onChange: setMinute,
style: {
width: "120%"
}
});
var legendLabels = [
createColorLabel('fire', 'red'),
createColorLabel('no-fire', 'olive'),
createColorLabel('clouds', 'cornsilk'),
createColorLabel('missing data or water', 'darkslateblue'),
createColorLabel('bad input data', 'green'),
createColorLabel('Algorithm failure', 'burlywood'),
]
var infoPanel = ui.Panel(legendLabels, ui.Panel.Layout.flow(),
{
width: "160px",
height: "208px",
textAlign: "center",
margin: "0px",
position: "bottom-right"
});
var hourLabel = createCenteredLabel("Hour")
var minuteLabel = createCenteredLabel("Minute")
var hourSliderPanel = ui.Panel({
style: {
margin: "auto",
height: "82px"
}
})
var minuteSliderPanel = ui.Panel({
style: {
margin: "0 0 0 10px",
height: "82px"
}
})
hourSliderPanel.add(hourLabel)
hourSliderPanel.add(hourSlider)
minuteSliderPanel.add(minuteLabel)
minuteSliderPanel.add(minuteSlider)
Map.add(dateSlider);
Map.add(hourSliderPanel);
Map.add(minuteSliderPanel);
Map.add(infoPanel);
Map.setCenter(CONFIG.mapInitLat,
CONFIG.mapInitLon,
CONFIG.mapInitZoom);
showPic();