GEE加入的集合无法在功能中使用

问题描述

我正在处理两个卫星数据集合。我想从“集合1”中选择特定的波段,将它们加入“集合2”,然后运行一个函数。不幸的是,该功能不适用于加入的数据,尽管它适用于“集合1”。

这里是仅使用Sentinel-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,'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;
}