0

How could I add a "NEW" Column of Data with DATES to this SCRIPT, for export as CSV

var dataset = ee.ImageCollection('UCSB-CHG/CHIRPS/DAILY')
                  .filter(ee.Filter.date('2021-01-01', '2021-12-31'));
                
var precipitation = dataset.select('precipitation');

var precipitationVis = {
  min: 1.0,
  max: 200.0,
  palette: ['001137', '0aab1e', 'e7eb05', 'ff4a2d', 'e90000'],
};

Map.addLayer(precipitation, precipitationVis, 'Precipitation');


var precipitation = precipitation.map(function(image) {
    return image
        .reduceRegions({ 
      collection:Micros,
      reducer: ee.Reducer.mean(), 
      scale: 5000,
        })
      .copyProperties(image, ['system:time_start']);
});

var region = ee.FeatureCollection ('users/santiagom/Micros')

Map.addLayer(region);
print (region) 


// visualizamos
Map.centerObject(region);
Map.addLayer(region,{},'region');


// Export 
Export.table.toDrive({
  collection: precipitation.flatten()
  description: 'Lluvias',
  fileFormat: 'CSV'
}); 
1
  • Thanks, done @TomazicM Jan 24, 2022 at 17:35

2 Answers 2

0

The tricky part is when you map over the precipitation image collection. This could be one approach:

var precipitation = precipitation.map(function(image) {
  
  var result = image
        .reduceRegions({ 
      collection:Micros,
      reducer: ee.Reducer.mean(), 
      scale: 5000,
        })
  var date = image.date().format('y-MM-dd')
  
  return result.map(function(feat){ return feat.set('DATE', date)})
});

Of course you can modify the date format to match your needs

1
  • Thank you!!! That worked perfect. :) Jan 26, 2022 at 15:51
0

Another approach, only adding selectors:

// Export 

Export.table.toDrive({
  collection: precipitation.flatten(),
  description: 'Lluvias',
  selectors:'precipitation'['system:index'],
  fileFormat: 'CSV'
});
 

I dont have access to your asset, so I created a new geometry, here the GEE code Link

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.