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
相关文章
|
编解码 算法 定位技术
GEE时序——利用sentinel-2(哨兵-2)数据进行地表物候学分析(时间序列平滑法估算和非平滑算法代码)
GEE时序——利用sentinel-2(哨兵-2)数据进行地表物候学分析(时间序列平滑法估算和非平滑算法代码)
1769 3
|
5月前
|
机器学习/深度学习 存储 人工智能
106_模型合并:Task Arithmetic
在大语言模型(LLM)时代,模型合并技术正在成为高效整合不同模型能力的关键方法。随着开源模型的爆发式增长,如何在不进行昂贵的重新训练的情况下,将多个专用模型的知识整合到一个统一模型中,成为了研究和工业界的重要课题。Task Arithmetic作为一种新兴的模型合并方法,通过向量操作实现权重融合,为这一挑战提供了创新解决方案。
|
编解码 数据可视化
Google Earth Engine——gee文件导出到drive:影像等大文件导出100000000超限解决办法
Google Earth Engine——gee文件导出到drive:影像等大文件导出100000000超限解决办法
3084 0
Google Earth Engine——gee文件导出到drive:影像等大文件导出100000000超限解决办法
|
XML 关系型数据库 MySQL
MySQL 导出某些数据的技术详解
MySQL 导出某些数据的技术详解
660 3
|
存储 监控 Go
面向OpenTelemetry的Golang应用无侵入插桩技术
文章主要讲述了阿里云 ARMS 团队与程序语言与编译器团队合作研发的面向OpenTelemetry的Golang应用无侵入插桩技术解决方案,旨在解决Golang应用监控的挑战。
1133 9
|
数据库
JSP+Servlet+JavaBean模式+实现登录注册
JSP+Servlet+JavaBean模式+实现登录注册
JSP+Servlet+JavaBean模式+实现登录注册
|
传感器 编解码 数据挖掘
GEE 影像下载——批量下载多源遥感影像(Landsat 8 C02 SR)光谱波段。光谱指数,缨帽变换和纹理特征以及SAR和地形数据(DEM)
GEE 影像下载——批量下载多源遥感影像(Landsat 8 C02 SR)光谱波段。光谱指数,缨帽变换和纹理特征以及SAR和地形数据(DEM)
1018 3
|
存储 编解码 数据可视化
Google Earth Engine获取随机抽样点并均匀分布在栅格的不同数值区中
【2月更文挑战第14天】本文介绍在谷歌地球引擎(Google Earth Engine,GEE)中,按照给定的地表分类数据,对每一种不同的地物类型,分别加以全球范围内随机抽样点自动批量选取的方法~
1320 1
Google Earth Engine获取随机抽样点并均匀分布在栅格的不同数值区中
GEE错误——超限问题解决Export too large: specified 375255165 pixels (max: 100000000)
GEE错误——超限问题解决Export too large: specified 375255165 pixels (max: 100000000)
604 10
|
SQL 关系型数据库 MySQL
性能提高20倍!MySQL排序引起的性能问题及解决方案
负责公司的用户收藏服务,收到调用方反馈有read time out的情况,进行排查发现是某用户收藏数量太多引起的(有业务设计上的问题,正常应只保留有限时间的收藏或者限制用户收藏的数量),一般用户收藏数是不超过100的,查询耗时是几毫秒,该用户收藏数2W+,查询耗时接近200毫秒。
4229 0