2

I want to calculate the number of fires for a region and export the result to Google Drive as a CSV file. The code I'm using to do this seems to work, but the object fire_ind_count contains many additional properties besides fire count.

How can I alter my code to obtain an object with only the count of fires to export?

// Load country shapefile 
var lsib = ee.FeatureCollection("USDOS/LSIB_SIMPLE/2017");
var vn_shape = lsib.filterMetadata('country_na', 'equals', 'Argentina');
print (vn_shape);

// Load fire counts image
var fire = ee.ImageCollection('FIRMS')
             .filterBounds(vn_shape)
             .filterDate('2019', '2020');
var scale = fire.first().projection().nominalScale();

// Filter fire with more than 50% confidence and add a new band representing areas where confidence of fire > 50%
var filterConfidence = function(image) {
  var line_number = image.select('line_number');
  var confidence = image.select('confidence');
  var conf_50 = confidence.gt(50).rename('confidence_50');
  var count_band = line_number.updateMask(conf_50).rename('count');
  return image.addBands(count_band);
};
var fire_conf = fire.map(filterConfidence);
print('fire_conf', fire_conf);

// Count for individual image.
var countIndividualImg = function(image) {
  var countObject = image.reduceRegion({
    reducer: ee.Reducer.countDistinct(),
    scale: scale,
    geometry: vn_shape,
    maxPixels: 1e9
  });
  return image.set(countObject);
};
var fire_ind_count = fire_conf.map(countIndividualImg);
print('fire_ind_count', fire_ind_count);
Export.table.toDrive({
  collection: fire_ind_count,
  description: 'FireCountsInAustralia_gt50_conf'});

1 Answer 1

5

By default, all properties of a collection will be exported. You can use the selectors argument to specify the properties you want to export.

Export.table.toDrive({
  collection: fire_ind_count,
  description: 'FireCountsInAustralia_gt50_conf',
  selectors:['count']
});

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.