I'm using Google Earth Engine's web-based code editor to grab a bunch of evapotranspiration snapshots, get a zonal mean, create a table of the results by date, and export to CSV. Code is below.
If I try to export using the raw date (from image.date()) for the date-data pair, I get "Error: Error: Feature: Invalid property name: **ee.Date**({"
followed by a whole pile of attributes. See image below.
If I try to convert the date to a string (curDate.format('YYYYMMDD')
), I get the same error, but it's "Error: Error: Feature: Invalid property name: **ee.String**({"
followed by the same. See image below.
Is there a different way I should be doing this?
// Get Data
var dataset = ee.ImageCollection('MODIS/NTSG/MOD16A2/105') // ET
.filter(ee.Filter.date('2000-01-01', '2015-01-01'))
.filterBounds(AOI);
var etDataset = dataset.select('ET');
var etDatasetList = etDataset.toList(etDataset.size());
var etDatasetSize = etDatasetList.size().getInfo();
// Process
var image;
var curDate;
var curDateString;
var meanDictionary
var data = [];
for(var i = 0; i <etDatasetSize; i++){
image = ee.Image(etDatasetList.get(i)).clip(AOI);
curDate = image.date();
curDateString = curDate.format('YYYYMMDD');
meanDictionary = image.reduceRegion({
reducer: ee.Reducer.mean(),
geometry: AOI
});
data[curDate] = meanDictionary; //For if I try to use the date itself
// data[curDateString] = meanDictionary; // For if I try to use the string
}
//Export
var feature = ee.Feature(null, data);
var featureCollection = ee.FeatureCollection([feature]);
Export.table.toDrive({
collection: featureCollection,
description: 'ET_Sample',
fileFormat: 'CSV'
});