I'm working on a script for calculating burn area statistics for multiple regions of interest using dNBR. The original script calculated burn area on a single region defined by a polygon and I've attempted to build upon it. I've gotten a bit stuck and would appreciate some advise on the best way of approaching the following workflow.

The workflow I'm aiming for is:

  • Import .shp containing buffers around points of interest
  • Run script to calculate burn area statistics for each individual region
  • Append resulting statistics (burn area in hectares for each burn severity class) to the feature collection and export the result.

I'm unsure if:

  • Can .set be used with lists? Desired fields to be added to the feature collection are: 'NA', 'High Severity', 'Moderate-high Severity', 'Moderate-low Severity', 'Low Severity','Unburned', 'Enhanced Regrowth, Low', 'Enhanced Regrowth, High'

Full script here: https://code.earthengine.google.com/6151358ab2813de7ffe6831fb5b43cd2

Problem child in lines 272 to 312, visible below:


// count number of pixels in entire layer
var allpix_hotspots =  classified.updateMask(classified);  // mask the entire layer

var pixstats_hotspots = allpix_hotspots.reduceRegions({
  reducer: ee.Reducer.count(),               // count pixels in a single region
  collection: buffer,
  scale: 30 

var allpixels_hotspots = ee.Number(buffer.get('sum')); // extract pixel count as a number

// create a function to derive extent of one burn severity class
// arguments are class number and class name
var areacount_hotspots = function(cnr, name) {
 var singleMask_hotspots =  classified.updateMask(classified.eq(cnr));  // mask a single class
 var stats_hotspots = singleMask_hotspots.reduceRegions({
  reducer: ee.Reducer.count(),               // count pixels in a single class
  collection: buffer,
  scale: 30

// severity classes
var names2 = ['NA', 'High Severity', 'Moderate-high Severity', 'Moderate-low Severity', 'Low Severity','Unburned', 'Enhanced Regrowth, Low', 'Enhanced Regrowth, High'];

var pix_hotspots =  ee.Number(stats_hotspots.get('sum'));
var hect_hotspots = pix_hotspots.multiply(900).divide(10000);                // Landsat pixel = 30m x 30m --> 900 sqm
var perc_hotspots = pix_hotspots.divide(allpixels_hotspots).multiply(10000).round().divide(100);   // get area percent by class and round to 2 decimals
buffer.set({names2: hect_hotspots});

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




Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.