When processing an ImageCollection in GEE my function drops the feature property system:time_start
but leaves segmentStartTime
. This means that I can't use ui.Chart.image.series
to plot the data. This is really minor as I do plotting locally. However, I'm curious about how to add a new feature property with unique values to an ImageCollection.
As you can see in the code below, I tried using .set(). This didn't work. Any pointers?
var s1_collection = ee.ImageCollection('COPERNICUS/S1_GRD')
.filterBounds(geometry)
.filterDate('2020-01-29', '2020-09-1')
.filter(ee.Filter.and(
ee.Filter.listContains('transmitterReceiverPolarisation', 'VV'),
ee.Filter.listContains('transmitterReceiverPolarisation', 'VH'),
ee.Filter.eq('instrumentMode', 'IW')
));
print(s1_collection);
var addVVVH = function(image) {
start = image.get('segmentStartTime')
var VVVH = image.select('VV').divide(image.select('VH')).rename('VVVH')
.copyProperties(image)
.set('system:time_start', start);
return image.addBands(VVVH);
};
var s1_collection2 = s1_collection.map(addVVVH);
print(s1_collection2);
/////////
var panel = ui.Panel();
panel.style().set('width', '300px');
var intro = ui.Panel([
ui.Label({
value: 'Two Chart Inspector',
style: {fontSize: '20px', fontWeight: 'bold'}
}),
ui.Label('Click point.')
]);
panel.add(intro);
var lon = ui.Label();
var lat = ui.Label();
panel.add(ui.Panel([lon, lat], ui.Panel.Layout.flow('horizontal')));
Map.onClick(function(coords) {
lon.setValue('lon: ' + coords.lon.toFixed(2)),
lat.setValue('lat: ' + coords.lat.toFixed(2));
var point = ee.Geometry.Point(coords.lon, coords.lat);
// Create S1 VV/VH chart
var sentinelVVChart = ui.Chart.image.series(s1_collection2.select('VVVH'), point)
.setChartType('ScatterChart')
.setOptions({
title: 'Sentinel backscatter (VV/VH)',
trendlines: {0: {
color: 'CC0000'
}},
lineWidth: 1,
pointSize: 3,
});
panel.widgets().set(1, sentinelVVChart);
});
Map.style().set('cursor', 'crosshair');
ui.root.insert(0, panel);