I am currently trying to export coordinates (and their values) of MODIS Aqua daily hotspot dataset for one month (November 2018). My idea is selecting a region using a rectangle geometry of the image collection, then get the values of 'MaxFRP' fields + pixel coordinates, and export them into a CSV file to my Drive.

Credits to Rodrigo E. Principe for sharing the initial code.

var aqua = ee.ImageCollection('MODIS/006/MYD14A1')
                  .filter(ee.Filter.date('2018-11-01', '2018-11-30'));
var fireMaskVis = {
  min: 9.936350984054926,
  max: 107.38312795164352,
  bands: ['MaxFRP', 'FireMask', 'FireMask'],
//Map.setCenter(6.746, 46.529, 2);
Map.addLayer(aqua, fireMaskVis, 'Fire Mask');

// Create a geometry representing an export region.
var geometry = ee.Geometry.Rectangle([71, 28, 77, 32]);
var region = ee.FeatureCollection(geometry)

var mapfunc = function(feat) {
  // get feature geometry
  var geom = feat.geometry()
  // function to iterate over the daily ImageCollection
  // the initial object for the iteration is the feature
  var addProp = function(img, f) {
    // cast Feature
    var newf = ee.Feature(f)
    // get date as string
    var date = img.date().format()
    // extract the value (first) of 'MaxFRP' in the feature
    var value = img.reduceRegion(ee.Reducer.first(), geom, 1000).get('MaxFRP')
    // if the value is not null, set the values as a property of the feature. The name of the property will be the date
    return ee.Feature(ee.Algorithms.If(value,
                                       newf.set(date, ee.String(value)),
                                       newf.set(date, ee.String('No data'))))
  var newfeat = ee.Feature(aqua.iterate(addProp, feat))
  return newfeat

var newft = region.map(mapfunc);

// Export

The result I got was just a CSV file with only date headers. This is my first time to work with Google Earth Engine, thus sorry for the coding mess.

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.