Earth Engine 将功能 属性 添加到 ImageCollection
Earth Engine add feature property to ImageCollection
在 GEE 中处理 ImageCollection 时,我的函数删除了特征 属性 system:time_start
但保留了 segmentStartTime
。这意味着我不能使用 ui.Chart.image.series
来绘制数据。这真的很小,因为我在本地绘图。但是,我很好奇如何向 ImageCollection 添加具有唯一值的新功能 属性。
正如您在下面的代码中看到的,我尝试使用 .set()。这没有用。有什么指点吗?
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);
你几乎答对了;需要在 return
语句之后设置日期。这是你的目标吗?
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) {
var VVVH = image.select('VV').divide(image.select('VH')).rename('VVVH')
.copyProperties(image)
return image.addBands(VVVH)
.set({'system:time_start': image.get('segmentStartTime')});
};
s1_collection = s1_collection.map(addVVVH);
print(s1_collection);
var chart = ui.Chart.image.series({
imageCollection: s1_collection.select('VVVH'),
region: geometry,
reducer: ee.Reducer.mean(),
scale: 10,
xProperty: 'date'
})
print(chart)
在 GEE 中处理 ImageCollection 时,我的函数删除了特征 属性 system:time_start
但保留了 segmentStartTime
。这意味着我不能使用 ui.Chart.image.series
来绘制数据。这真的很小,因为我在本地绘图。但是,我很好奇如何向 ImageCollection 添加具有唯一值的新功能 属性。
正如您在下面的代码中看到的,我尝试使用 .set()。这没有用。有什么指点吗?
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);
你几乎答对了;需要在 return
语句之后设置日期。这是你的目标吗?
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) {
var VVVH = image.select('VV').divide(image.select('VH')).rename('VVVH')
.copyProperties(image)
return image.addBands(VVVH)
.set({'system:time_start': image.get('segmentStartTime')});
};
s1_collection = s1_collection.map(addVVVH);
print(s1_collection);
var chart = ui.Chart.image.series({
imageCollection: s1_collection.select('VVVH'),
region: geometry,
reducer: ee.Reducer.mean(),
scale: 10,
xProperty: 'date'
})
print(chart)