giovedì 12 febbraio 2026

Anomalie in NDVI

Questo script calcola l'anomalia dell'NDVI rispetto ad un valore medio

Unica accortezza.: non sono stati presi dati di Landsat 8 e 9 perche' si fondono male con Landsat 7






Map.centerObject(areaOfInterest, 15);
// 2. Funzione per NDVI scalato
var getNDVI = function(image) {
  var optical = image.multiply(0.0000275).add(-0.2);
  return optical.normalizedDifference(['SR_B4', 'SR_B3']).rename('NDVI')
    .copyProperties(image, ['system:time_start']);
};
// 3. Collezioni Landsat 4, 5, 7
var collection = ee.ImageCollection("LANDSAT/LT05/C02/T1_L2")
  .merge(ee.ImageCollection("LANDSAT/LE07/C02/T1_L2"))
  .filterBounds(areaOfInterest)
  .map(getNDVI);
// 4. CREAZIONE DELLE DUE EPOCHE (Baseline vs Recente)
// Epoca 1: Il passato (es. 1984-1994)
var past = collection.filterDate('1984-01-01', '1994-12-31').median();
// Epoca 2: Il presente (es. 2012-2022)
var present = collection.filterDate('2012-01-01', '2022-12-31').median();
// 5. CALCOLO DELLA MAGNITUDO DEL CAMBIAMENTO
// Differenza tra oggi e ieri
var change = present.subtract(past);
// 6. VISUALIZZAZIONE
var changeViz = {
  min: -0.3,
  max: 0.3,
  palette: ['#d73027', '#f4a582', '#f7f7f7', '#d9f0d3', '#1a9850']
};
Map.addLayer(past.clip(areaOfInterest), {min:0, max:0.8}, 'NDVI Passato (Anni 80/90)', false);
Map.addLayer(present.clip(areaOfInterest), {min:0, max:0.8}, 'NDVI Recente (Anni 2000/10)', false);
Map.addLayer(change.clip(areaOfInterest), changeViz, 'Cambiamento Netto (Magnitudo)');
// 7. Esportazione PNG del Cambiamento
var exportImg = change.visualize(changeViz);
print('Link PNG Cambiamento Storico:', exportImg.getThumbURL({
  dimensions: 1024,
  region: areaOfInterest,
  format: 'png'
}));


Nessun commento:

Posta un commento

Anomalie in NDVI con algoritmo Continuous Change Detection (CCDC)

Attenzione: questo plugin non funziona su Debian 13 per delle dipendenze non risolte. Funziona in modo corretto su  Debian 12 con QGis 3.22 ...