-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathnbr_calculator.js
More file actions
139 lines (119 loc) · 4.62 KB
/
nbr_calculator.js
File metadata and controls
139 lines (119 loc) · 4.62 KB
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
/**
* Script de Cálculo de NBR (Normalized Burn Ratio)
*
* Autor: Tássia Parada Sampaio
* Instituição: Universidade Federal de Pelotas (UFPEL)
* Curso: Engenharia Ambiental e Sanitária
* Data: 2023
*
* Descrição: Este script calcula o Índice de Queimada Normalizado (NBR)
* usando imagens do Sentinel-2 para monitoramento de severidade de queimadas.
*
* Referência: Sampaio, T. P. (2023). Análise Automatizada da Severidade de
* Queimadas em Área de Banhado com índices de vegetação (NDVI e NBR) através
* de JavaScript: Um Estudo de Caso em Pelotas, RS.
*/
// ============================================================================
// DEFINIÇÃO DA REGIÃO DE INTERESSE (ROI)
// ============================================================================
// Pontal da Barra, Pelotas/RS - Coordenadas em WGS84
var roi = ee.Geometry.Polygon([
[-52.23242174143157, -31.78621134386096],
[-52.23242174143157, -31.78127497081573],
[-52.22064979507719, -31.78127497081573],
[-52.22064979507719, -31.78621134386096]
]);
// ============================================================================
// FUNÇÃO PARA CALCULAR NBR
// ============================================================================
/**
* Calcula o Índice de Queimada Normalizado (NBR)
* Fórmula: NBR = (NIR - SWIR) / (NIR + SWIR)
* Onde:
* - NIR (Near Infrared): Banda 8A do Sentinel-2
* - SWIR (Short Wave Infrared): Banda 11 do Sentinel-2
*
* Valores:
* - Próximo de 1: Áreas não afetadas pelo fogo
* - Próximo de -1: Áreas severamente queimadas
*/
var calculateNBR = function(image) {
var B8A = image.select('B8A'); // NIR Estreita
var B11 = image.select('B11'); // SWIR 1
var nbr = B8A.subtract(B11)
.divide(B8A.add(B11))
.rename('NBR');
return image.addBands(nbr);
};
// ============================================================================
// FUNÇÃO PARA CALCULAR MÉDIA MENSAL DE NBR
// ============================================================================
/**
* Calcula a média mensal do NBR para um período específico
*/
var calculateMonthlyNBR = function(startYear, endYear, month) {
var startDate = ee.Date.fromYMD(startYear, month, 1);
var endDate = ee.Date.fromYMD(endYear, month, 1).advance(1, 'month');
// Filtrar imagens do Sentinel-2 usando data e região de interesse
var collection = ee.ImageCollection('COPERNICUS/S2_SR')
.filterBounds(roi)
.filterDate(startDate, endDate)
.map(calculateNBR);
// Reduzir a coleção para a média mensal
var monthlyNBR = collection.mean();
// Obter a média do NBR na região de interesse
var meanNBR = monthlyNBR.reduceRegion({
reducer: ee.Reducer.mean(),
geometry: roi,
scale: 10
});
return meanNBR.get('NBR');
};
// ============================================================================
// INTERFACE DO USUÁRIO
// ============================================================================
var startYear = 2022;
var endYear = 2023;
var monthSelect = ui.Select({
items: ['11', '12', '01', '02', '03', '04', '05'],
onChange: function(month) {
var selectedYear = (parseInt(month, 10) === 1 || parseInt(month, 10) === 2)
? endYear
: startYear;
var meanNBR = calculateMonthlyNBR(selectedYear, selectedYear, parseInt(month, 10));
print('Média do NBR para o mês ' + month + '/' + selectedYear + ':', meanNBR.getInfo());
}
});
var panel = ui.Panel({
widgets: [
ui.Label('Selecione o mês para análise de NBR:'),
monthSelect
],
style: {width: '250px', padding: '10px'}
});
ui.root.add(panel);
// ============================================================================
// VISUALIZAÇÃO INICIAL
// ============================================================================
// Calcular NBR para o primeiro mês (Novembro de 2022)
var initialCollection = ee.ImageCollection('COPERNICUS/S2_SR')
.filterBounds(roi)
.filterDate('2022-11-01', '2022-11-30')
.map(calculateNBR);
var initialNBR = initialCollection.mean();
// Visualizar o resultado
Map.addLayer(initialNBR.select('NBR'), {
min: -1,
max: 1,
palette: ['red', 'yellow', 'green']
}, 'NBR - Novembro 2022');
Map.centerObject(roi, 16);
// ============================================================================
// INFORMAÇÕES TÉCNICAS
// ============================================================================
// Satélite: Sentinel-2A e Sentinel-2B
// Resolução Espacial: 10-60 metros
// Resolução Temporal: 5 dias
// Bandas Utilizadas: B8A (NIR Estreita) e B11 (SWIR 1)
// Período de Análise: Novembro 2022 a Maio 2023
// Área de Estudo: Pontal da Barra, Pelotas/RS