Springe direkt zu Inhalt

NDVI - التصنيف وحساب المنطقة

كخطوة أخيرة لتحليل المراقبة لدينا، يجب في تصنيف صورة NDVI الخاصة بنا وحساب المنطقة ونسبة الغطاء وعدد البيكسل لكل فئة.

في حالة ظهور خطأ في حسابات المنطقة، ما عليك سوى تشغيل البرنامج الكودي مرة أخرى لإصلاحه.

يتم عرض الفيديو الداعم لتخطي أوقات المعالجة أثناء حساب المنطقة.

https://un-spider.org/advisory-support/recommended-practices/recommended-practice-burn-severity/burn-severity-earth-engine

تصنيف

يسمح GEE بإعادة تعيين قيم NDVI في فئات، بحيث نتلقى صورة بقيم صحيحة تتراوح من 0 إلى) n يمثل n عدد الفئات).

يتم ذلك عن طريق تعيين قيم الحد وتلخيص جميع القيم التي تكون إما أقل أو أكبر من تلك العتبات.

بالنسبة لمؤشر NDVI، سنعيد تخطيط صورتنا إلى 7 فئات: قيم أصغر من -0.2 و0 و0.1 و0.2 و 0.3 و 0.4 و 1.

var thresholds = ee.Image([-0.1, -0.251, -0.101, 0.99, 0.269, 0.439, 0.659, 2]); //Define the thresholds
var classified = pre_event.gt(thresholds).reduce('sum').toInt(); //Create the classified Image
print(classified, 'Classified');

//Define new visualization parameters for the classification: The values are now ranging from 0 to 8, one for each class
var classifiedParams = {min: 0, max: 8, palette: [ '#ffffff','#7a8737', '#acbe4d','#0ae042', '#fff70b', '#ffaf38', '#ff641b', '#a41fd6']};
Map.addLayer(classified.clip(extent_aoi), classifiedParams, 'Classified');

//Have a look at the classification in the map panel!

حساب المنطقة لكل فئة

الآن بعد أن قمنا بتصنيف صورة NDVI الخاصة بنا، دعنا نلقي نظرة على إحصائيات المنطقة للفئات الفردية.

النهج التالي مقتبس من التطبيقات الموصى بها لرسم خرائط خطورة الحروق في الأمم المتحدة.

تأكد من إلقاء نظرة عليها، حيث إنها مفيدة للغاية ومكتوبة بشكل جيد!

https://un-spider.org/advisory-support/recommended-practices/recommended-practice-burn-severity/burn-severity-earth-engine

اعتمادًا على حجم الشكل الهندسي  AOI الخاص بك، قد يعرض GEE الخطأ "Invalid JSON:" عند محاولة فحص إحصائيات المنطقة المحسوبة.

ما عليك سوى تشغيل الكود مرة أخرى، ويجب أن يعمل بشكل جيد.

// First, we want to count the number of pixels in the entire layer for future reference.
var allpix =  classified.updateMask(classified);  // mask the entire layer
var pixstats = allpix.reduceRegion({
  reducer: ee.Reducer.count(),               // count all pixels in a single class
  geometry: extent_aoi,
  scale: 30,
  maxPixels: 1e10
  });
var allpixels = ee.Number(pixstats.get('sum')); // extract pixel count as a number


// Then, we want to create an empty list to store the area values we will calculate in
var arealist = [];

// Now, we can create a function to derive the extent of one NBR class
// The arguments are class number (cnr) and class name (name)
var areacount = function(cnr, name) {
 var singleMask =  classified.updateMask(classified.eq(cnr));  // mask a single class
 var stats = singleMask.reduceRegion({
  reducer: ee.Reducer.count(),               // count pixels in a single class
  geometry: extent_aoi,
  scale: 30,
  maxPixels: 1e10
  });
var pix =  ee.Number(stats.get('sum'));
var hect = pix.multiply(900).divide(10000);                // Landsat pixel = 30m x 30m --> 900 sqm
var perc = pix.divide(allpixels).multiply(10000).round().divide(100);   // get area percent by class and round to 2 decimals
arealist.push({Class: name, Pixels: pix, Hectares: hect, Percentage: perc});
};

// Create a list that contains the NBR class names (8 classes, ranging from [-1, -0.251, -0.101, 0.99, 0269, 0.439, 0.659, 2])
var names2 = ['Enhanced Regrowth, High', 'Enhanced Regrowth, Low', 'Unburned', 'Low Severity', 'Moderate-low Severity', 'Moderate-high Severity', 'High Severity', 'NA'];

// execute function for each class
for (var i = 0; i < 8; i++) {
  areacount(i, names2[i]);
  }

//Print the results to the Console and examine it.
print('Vegetated Area by NDVI Class', arealist, '--> click list objects for individual classes');