GEE加入的集合在函数中不起作用



我正在处理两组卫星数据。我想从";集合1";,加入他们的";集合2";,然后运行一个函数。不幸的是,该函数不适用于联接的数据,尽管它适用于";集合1";。

这里是一个使用哨兵-2 的B10的例子

//identifying area and date
var geometry = ee.Geometry.Point([4,45]);
Map.centerObject(geometry,10);
var start = '2019-03-10';
var end   = '2019-05-10';

//my function
function testing(img){
img = img.updateMask(img.select(['B10']).gt(200).focal_min(2).focal_max(2).not());
return img;
}
//my two collections
var collection1 = ee.ImageCollection('COPERNICUS/S2').filterDate(start,end)
.filterBounds(geometry);

var B10s=collection1.select('B10');
//print('B10s',B10s);

var collection2 = ee.ImageCollection('COPERNICUS/S2_SR')
.filterDate(start,end)
.filterBounds(geometry);

// joining the collections
var filtering = ee.Filter.equals({
leftField: 'system:time_start',
rightField: 'system:time_start'
});
var simpleJoin = ee.Join.inner();
var innerJoin = simpleJoin.apply(collection2, B10s, filtering);
var joined = innerJoin.map(function(feature) {
return ee.Image.cat(feature.get('primary'), feature.get('secondary'));
});
print('Joined', joined);
//just to visualize one image
//var coll1 = ee.Image(collection1.first());
//Map.addLayer(coll1, {bands:['B2'], min:0, max:5000},'B2Coll1 test');
//running the function for collection 1 works
var test = collection1.map(testing);
var tess = ee.Image(test.first());
Map.addLayer(tess, {bands:['B2'], min:0, max:5000},'B2 test');
//here when running with the joined collection, there is a problem
var TestingJoined = joined.map(testing);

错误为:img.select(...).gt is not a function

我该如何做到这一点?

调试时,联接是否按预期工作?日期时间太精确,不允许完全加入,这有什么问题吗?

我要走的第二条路是确保连接的对象与集合相同。如果没有你铸造它或其他东西,我怀疑情况会是这样(尽管我不熟悉这个库(。您的";测试";映射到这些集合的函数可能只适用于未连接的集合。如果您提供实际的"问题"或错误输出,将非常有帮助。

好的。我解决了。谢谢你的意见。我需要在函数中使用强制转换。现在它起作用了。

function testing(img){
img = ee.Image(img).updateMask(ee.Image(img).select(['B10']).gt(200).focal_min(2).focal_max(2).not());
return img;
}

最新更新