I am currently working on a time-series in Google Earth Engine. Iam still quite inexperienced, especially when it comes to functions. I want to extract the mean values of Sentinel1-images for each week in a period of 7 month and aggregate them into a new Image Collection I can then further process.
So far I tried to do it for a single month:
var testsubset = ee.FeatureCollection("users/xyz/test_subset");
//set start-dates
var images = {
'2018-02-01': getWeeklySentinelComposite('2018-02-01'),
'2018-02-08': getWeeklySentinelComposite('2018-02-08'),
'2018-02-15': getWeeklySentinelComposite('2018-02-15'),
'2018-02-22': getWeeklySentinelComposite('2018-02-22'),
'2018-03-01': getWeeklySentinelComposite('2018-03-01')
};
//function to get a weekly composite
function getWeeklySentinelComposite(date) {
var date = ee.Date(date);
// Only include the VV polarization, for consistent compositing.
var polarization = 'VV';
var sentinel1 = ee.ImageCollection('COPERNICUS/S1_GRD')
.filterBounds(testsubset)
.filterDate(date, date.advance(1, 'week'))
.filter(ee.Filter.listContains('transmitterReceiverPolarisation', polarization))
.filter(ee.Filter.eq('instrumentMode', 'IW'))
.select(polarization)
.mean();
return sentinel1;
}
I currently run into two main issues: I'am not sure how to return the images I picked and how to turn them into a new ImageCollection. Second: I get
"Invalid argument specified for ee.Date(): [object Object]"
and don't really know why (I used a similar function for another script and it worked fine)
Just to clarify, this is what I want to do with the Image Collection in the end:
//Map.addLayer(testsubset, {color:'green'}, 'Testshape', true , 0.5);
var tempTimeSeries = ui.Chart.image.series({
imageCollection: sentinel1_IC,
region: testsubset,
reducer: ee.Reducer.mean(),
scale: 200,
xProperty: 'system:time_start'
});
tempTimeSeries.setChartType('ScatterChart');
tempTimeSeries.setOptions({
title: 'VV-over-time',
vAxis: {
title: 'sigma VV'
},
lineWidth: 1,
pointSize: 4,
series: {
0: {color: 'blue'},
1: {color: 'red'},
2: {color: 'green'}
}
});
print(tempTimeSeries);