javascript - Earth Engine 将特征属性添加到 ImageCollection
问题描述
在 GEE 中处理 ImageCollection 时,我的函数删除了 feature 属性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)
推荐阅读
- javascript - .NET JavaScript 无法检索文件
- php - 将来自 mysql 查询的 json 响应填充到另一个文件中的 html 列表
- javascript - 如何管理对异步服务的可变调用次数
- android - 如何将 ResourceBundles 与 Android Studio 和 Gradle 一起使用?
- css - CSS 不能在 Firefox 上工作,但在 chrome 上工作
- python - Keras:逐元素操作:点积或内积,numpy.matmul 等效
- typescript - rxjs 在使用 HttpClient 时的困惑
- android - 自定义地标 MapKit
- java - 检查相机是否正在记录笔记本电脑屏幕
- sorting - Gremlin:如何选择()多个顶点到一个集合中,然后获取具有最高属性值的那个