On Google Earth Engine, I'd like to accomplish two tasks:
extract data from every pixel, across a time-series, within the given geometry bounds and save it as a table.
I need a column which prints the date of the image.
For the first part here is my code snippet (borrowed from : Extract complete pixel values inside a geometry) ---
// the geometry bounds
var rectangle = ee.Geometry.Rectangle(96.01669, 18.52621, 96.04819, 18.49634);
//the time series dataset
var dataset = ee.ImageCollection("MODIS/006/MOD13Q1")
.filterDate('2000-01-01', '2000-03-31')
.filterBounds(rectangle)
.select('NDVI', 'SummaryQA');
// Sort the dataset
var sorteddataset = dataset.sort('system:time_start', true);
var first = sorteddataset.first();
// generate a new image containing lat/lon of the pixel and reproject
// it to MODIS projection
var coordsImage =
ee.Image.pixelLonLat().reproject(first.projection());
var joinedImage = coordsImage.addBands(first);
var valuesList = joinedImage.reduceRegion({
reducer: ee.Reducer.toList(4),
geometry: rectangle
}).values().get(0);
valuesList = ee.List(valuesList) // Cast valuesList
var myFeatures = ee.FeatureCollection(valuesList.map(function(el){
el = ee.List(el) // cast every element of the list
var geom = ee.Geometry.Point([ee.Number(el.get(0)),
ee.Number(el.get(1))])
return ee.Feature(geom, {'NDVI':ee.Number(el.get(2)),
'SummaryQA':ee.Number(el.get(3))})
}))
Export.table.toDrive(results,
"data",
"ndvi-testing",
"NDVI-SummaryQA",
"CSV");
How do I modify the code to include the entire time-series instead of just the first image?
And how can I include a command that prints the image date?
Below is the image of the table I get from the given code.