Springe direkt zu Inhalt

NBR - التصنيف وحساب المساحة

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

   

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

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

تصنيف

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

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

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

var thresholds = ee.Image([-0.2, 0, 0.1, 0.2, 0.3, 0.4, 1]); //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 7, one for each class
var classifiedParams = {min: 0, max: 7, palette: ['blue', 'white', 'brown', 'burlywood', 'LimeGreen', 'ForestGreen', 'DarkGreen']};
Map.addLayer(classified.clip(extent_aoi), classifiedParams, 'Classified');

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

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

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

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

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

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 NDVI 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 NDVI class names (7 classes, ranging from [-0.2, 0, 0.1, 0.2, 0.3, 0.4, 1])
var names2 = ['Water', 'No Vegetation', 'Very Low Vegetation',
'Low Vegetation', 'Moderate Vegetation','Moderate-high Vegetation', 'High Vegetation'];

// execute function for each class
for (var i = 0; i < 7; 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');