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

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

问题:

我有两个具有相同 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, ordering, ascending, measureKey, outer)

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, 2
相关文章
|
2月前
|
SQL 定位技术 API
GEE python:按照矢量中的几何位置、属性名称和字符串去筛选矢量集合
GEE python:按照矢量中的几何位置、属性名称和字符串去筛选矢量集合
48 0
|
11月前
|
搜索推荐 Linux Python
VET:一个基于R语言的VCF数据提取工具,支持按基因ID、物理位置、样品名称提取指定变异信息
VET:一个基于R语言的VCF数据提取工具,支持按基因ID、物理位置、样品名称提取指定变异信息
|
2月前
|
算法 测试技术 C#
【多数组合 数学 字符串】2514. 统计同位异构字符串数目
【多数组合 数学 字符串】2514. 统计同位异构字符串数目
|
2月前
|
图形学 计算机视觉
GEE错误——如何将原有矢量将维度转化为地理坐标系,重投影坐标坐标无法实现?
GEE错误——如何将原有矢量将维度转化为地理坐标系,重投影坐标坐标无法实现?
45 0
|
12月前
|
传感器 编解码 计算机视觉
使用星凸随机超曲面模型对扩展对象和分组目标进行形状跟踪(Matlab代码实现)
使用星凸随机超曲面模型对扩展对象和分组目标进行形状跟踪(Matlab代码实现)
使用星凸随机超曲面模型对扩展对象和分组目标进行形状跟踪(Matlab代码实现)
|
定位技术
ArcGIS相交分析Intersect:了解某一区域中有多少个其他矢量要素
本文介绍在ArcMap软件中,基于相交分析,实现两个具有多要素的要素集之间相互重叠关系的分析~
389 1
ArcGIS相交分析Intersect:了解某一区域中有多少个其他矢量要素
|
Python
Python经典编程习题100例:第44例:两个 3 行 3 列的矩阵,实现其对应位置的数据相加,并返回一个新矩阵
Python经典编程习题100例:第44例:两个 3 行 3 列的矩阵,实现其对应位置的数据相加,并返回一个新矩阵
271 0
PIE-engine 教程 ——矢量集合的循环计算使用for循环(中国各省市面积统计)
PIE-engine 教程 ——矢量集合的循环计算使用for循环(中国各省市面积统计)
103 0
PIE-engine 教程 ——矢量集合的循环计算使用for循环(中国各省市面积统计)
|
算法 Python
实用算法题:excel表列序号与十进制数字的互相转化算法讲解!
实用算法题:excel表列序号与十进制数字的互相转化算法讲解!
284 0
|
机器学习/深度学习 移动开发
【组合数学】排列组合 ( 集合组合、一一对应模型分析示例 )
【组合数学】排列组合 ( 集合组合、一一对应模型分析示例 )
173 0