GEE——土地利用分类种两个矢量集合中不同列进行相减的方式(利用join进行连接处理)

在Google Earth Engine (GEE) 中,针对两个具有相同ID的特征集,如何实现逐个单元格的相减操作。原始问题涉及到使用ee.Join.saveFirst和ee.Join.apply函数来实现,但未能达到预期效果。博客内容探讨了如何正确应用这些函数以匹配并减去相应ID的单元格值。
摘要由CSDN通过智能技术生成

问题:

我有两个具有相同 ID 的特征集,我想从第二个特征集中减去第一个特征集的表格单元格。

我使用了这个函数,但它计算的是表 1 中第一个元素与表 2 中其他元素的减法。

我想逐个单元格计算减法。第一个表格中 id 为 1 的单元格减去第二个表格中 id 为 1 的单元格,2x2、3x3...

有人能帮我完成这项任务吗?
 

var result = falsealarms.map(function(falsealarms){
  var idb = falsealarms.get('id');
  var valuea = omission.filter(ee.Filter.eq('id', idb)).first().get('count');
  var resultvalue = ee.Number(falsealarms.get('count')).subtract(valuea);
  return omission.set('result', resultvalue)
});

使用它们旨在从两个集合中查找匹配的元素。

函数

ee.Join.saveFirst(matchKey, orderingascendingmeasureKeyouter)

Returns a join that pairs each element from the first collection with a matching element from the second collection. The first match is added to the result as an additional property.

Arguments:

matchKey (String):

The property name used to save the match.

ordering (String, default: null):

The property on which to sort the matches before selecting the first.

ascending (Boolean, default: true):

Whether the ordering is ascending.

measureKey (String, default: null):

An optional property name used to save the measure of the join condition on the match.

outer (Boolean, default: false):

If true, primary rows without matches will be included in the result.

Returns: Join

apply(primary, secondary, condition)

Joins two collections.

Arguments:

this:join (Join):

The join to apply; determines how the the results are constructed.

primary (FeatureCollection):

The primary collection.

secondary (FeatureCollection):

The secondary collection.

condition (Filter):

The join condition used to select the matches from the two collections.

Returns: FeatureCollection

原始代码:

//define the study area 
var roi = roi.filter(ee.Filter.inList('Nomencl', ['SH-21-X-D']));

Map.centerObject(roi, 10) 

Deforestation Mapbiomas/

//Select the t mapbiomas land use classification
var mabiomas_t = ee.Image('projects/mapbiomas-workspace/public/collection8/mapbiomas_collection80_integration_v1')
                   .clip(roi) 
                   .select('classification_2000'); 

// create a list of land use classes from the classification
var fromList = [3, 4, 5, 6, 49, 11, 12, 50, 32, 29, 13, 15, 18, 19, 39, 20, 40, 62, 41, 36, 46, 47, 35, 48, 9, 21, 23, 24, 30, 25, 33, 31, 27];

// A corresponding list of replacement values 
var toList =  [1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2];

// performs the reclassification
var t_remap = mabiomas_t.remap({
  from: fromList,
  to: toList,
  defaultValue: 0,
  bandName: 'classification_2000'
}).reproject('EPSG:4326', null, 30);
//Map.addLayer(t_remap)

//Select the vegetation land use class
var veg_class_t = t_remap.eq(1) 
//Map.addLayer(veg_class_t, null, 'veg_class_mapbiomas')

//Select the t + 1 mapbiomas land use classification
var mapbiomas_t1 = ee.Image('projects/mapbiomas-workspace/public/collection8/mapbiomas_collection80_integration_v1')
                   .clip(roi) 
                   .select('classification_2020'); 

var fromList = [3, 4, 5, 6, 49, 11, 12, 50, 32, 29, 13, 15, 18, 19, 39, 20, 40, 62, 41, 36, 46, 47, 35, 48, 9, 21, 23, 24, 30, 25, 33, 31, 27];

// A corresponding list of replacement values 
var toList =  [10, 10, 10, 10, 10, 10, 10, 10, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20,
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

此星光明

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值