Google Earth Engine:对NDVI进行惠特克平滑算法进行长时序分析

news/2024/9/18 4:49:44/ 标签: 算法, gee, 平滑算法, 惠特克, javascript, ndvi, 时序

目录

简介

函数

ee.Array.identity(size)

Arguments:

Returns: Array

transpose(axis1, axis2)

Arguments:

Returns: Array

matrixMultiply(image2)

Arguments:

Returns: Image

matrixSolve(image2)

Arguments:

Returns: Image

arrayFlatten(coordinateLabels, separator)

Arguments:

Returns: Image

arrayReduce(reducer, axes, fieldAxis)

Arguments:

Returns: Image

代码

结果


简介

惠特克(GEE)平滑算法是一种用于时间序列预测的统计方法,特别适用于非线性、非平稳和非高斯的数据。该算法基于广义估计方程,通过最小化残差的平方和来拟合数据并找到最佳的平滑曲线。

GEE平滑算法的主要思想是在时间序列数据中引入一个平滑函数来描述数据的趋势和周期性变化。该平滑函数由一系列基函数的线性组合组成,其中每个基函数具有不同的频率和振幅。通过调整基函数的权重,可以得到最佳的平滑曲线,以最大程度地拟合数据。

在实际应用中,GEE平滑算法通常与其他统计方法结合使用,例如自回归移动平均模型(ARIMA)或指数平滑法。通过将GEE平滑算法与其他方法相结合,可以进一步提高时间序列的预测准确度和稳定性。

总的来说,GEE平滑算法是一种针对非线性、非平稳和非高斯数据的时间序列预测方法,通过引入一个平滑函数来描述数据的趋势和周期性变化,以最大程度地拟合数据。它在实际应用中通常与其他统计方法结合使用,以进一步提高预测的准确度和稳定性。

函数

ee.Array.identity(size)

Creates a 2D identity matrix of the given size.

创建一个给定大小的二维标识矩阵。

Arguments:

size (Integer):

The length of each axis.

Returns: Array

transpose(axis1axis2)

Transposes two dimensions of an array.

平移数组的两个维度。

Arguments:

this:array (Array):

Array to transpose.

axis1 (Integer, default: 0):

First axis to swap.

axis2 (Integer, default: 1):

Second axis to swap.

Returns: Array

matrixMultiply(image2)

Returns the matrix multiplication A * B for each matched pair of bands in image1 and image2. If either image1 or image2 has only 1 band, then it is used against all the bands in the other image. If the images have the same number of bands, but not the same names, they're used pairwise in the natural order. The output bands are named for the longer of the two inputs, or if they're equal in length, in image1's order. The type of the output pixels is the union of the input types.

返回图像 1 和图像 2 中每对匹配波段的矩阵乘法 A * B。如果图像 1 或图像 2 中只有一个波段,则该波段将与另一幅图像中的所有波段相对应。如果图像中的条带数量相同,但名称不同,则按自然顺序成对使用。输出波段以两个输入波段中较长的一个命名,如果两个输入波段长度相等,则按图像 1 的顺序命名。输出像素的类型是输入类型的组合。

Arguments:

this:image1 (Image):

The image from which the left operand bands are taken.

image2 (Image):

The image from which the right operand bands are taken.

Returns: Image

matrixSolve(image2)

Solves for x in the matrix equation A * x = B, finding a least-squares solution if A is overdetermined for each matched pair of bands in image1 and image2. If either image1 or image2 has only 1 band, then it is used against all the bands in the other image. If the images have the same number of bands, but not the same names, they're used pairwise in the natural order. The output bands are named for the longer of the two inputs, or if they're equal in length, in image1's order. The type of the output pixels is the union of the input types.

求解矩阵方程 A * x = B 中的 x,如果 A 对图像 1 和图像 2 中每对匹配的波段都是过确定的,则找到最小二乘法解。如果图像 1 或图像 2 中只有一个波段,则使用该波段与另一幅图像中的所有波段进行比对。如果图像中的波段数相同,但名称不相同,则按自然顺序成对使用。输出波段以两个输入波段中较长的一个命名,如果两个输入波段长度相等,则按图像 1 的顺序命名。输出像素的类型是输入类型的组合。

Arguments:

this:image1 (Image):

The image from which the left operand bands are taken.

image2 (Image):

The image from which the right operand bands are taken.

Returns: Image

arrayFlatten(coordinateLabels, separator)

Converts a single-band image of equal-shape multidimensional pixels to an image of scalar pixels, with one band for each element of the array.

将等形多维像素的单波段图像转换为标量像素图像,阵列中的每个元素对应一个波段。

Arguments:

this:image (Image):

Image of multidimensional pixels to flatten.

coordinateLabels (List):

Name of each position along each axis. For example, 2x2 arrays with axes meaning 'day' and 'color' could have labels like [['monday', 'tuesday'], ['red', 'green']], resulting in band names'monday_red', 'monday_green', 'tuesday_red', and 'tuesday_green'.

separator (String, default: "_"):

Separator between array labels in each band name.

Returns: Image

arrayReduce(reducer, axes, fieldAxis)

Reduces elements of each array pixel.

减少每个阵列像素的元素。

Arguments:

this:input (Image):

Input image.

reducer (Reducer):

The reducer to apply.

axes (List):

The list of array axes to reduce in each pixel. The output will have a length of 1 in all these axes.

fieldAxis (Integer, default: null):

The axis for the reducer's input and output fields. Only required if the reducer has multiple inputs or outputs.

Returns: Image

代码

javascript">//加载研究区
var geometry = /* color: #d63000 *//* displayProperties: [{"type": "rectangle"}] */ee.Geometry.Polygon([[[113.44773227683973, 38.6708907304602],[113.44773227683973, 38.64783484482313],[113.47588474266004, 38.64783484482313],[113.47588474266004, 38.6708907304602]]], null, false);// 将 qa 位图像转换为标志的辅助函数
function extractBits(image, start, end, newName) {// 计算我们需要提取的比特。var pattern = 0;for (var i = start; i <= end; i++) {pattern += Math.pow(2, i);}// 返回提取的质量保证位的单波段图像,并为该波段命名。return image.select([0], [newName]).bitwiseAnd(pattern).rightShift(start);
}// 在输入矩阵上获取指定阶次的差分矩阵的函数。将矩阵和阶次作为参数
function getDifferenceMatrix(inputMatrix, order){var rowCount = ee.Number(inputMatrix.length().get([0]));var left = inputMatrix.slice(0,0,rowCount.subtract(1));var right = inputMatrix.slice(0,1,rowCount);if (order > 1 ){return getDifferenceMatrix(left.subtract(right), order-1)}return left.subtract(right);
};// 将数组图像解包为图像和波段
// 以数组图像、图像 ID 列表和乐队名称列表为参数
function unpack(arrayImage, imageIds, bands){function iter(item, icoll){function innerIter(innerItem, innerList){return ee.List(innerList).add(ee.String(item).cat("_").cat(ee.String(innerItem)))}var temp = bands.iterate(innerIter, ee.List([]));return ee.ImageCollection(icoll).merge(ee.ImageCollection(ee.Image(arrayImage).select(temp,bands).set("id",item)))}var imgcoll  = ee.ImageCollection(imageIds.iterate(iter, ee.ImageCollection([])));return imgcoll}// 用于计算回归结果的反对数比率并转换回百分比单位的函数
function inverseLogRatio(image) {var bands = image.bandNames();var t = image.get("system:time_start");var ilrImage = ee.Image(100).divide(ee.Image(1).add(image.exp())).rename(bands);return ilrImage.set("system:time_start",t);
}function whittakerSmoothing(imageCollection, isCompositional, lambda){// 快速配置以设置默认值if (isCompositional === undefined || isCompositional !==true) isCompositional = false;if (lambda === undefined ) lambda = 10;// 程序启动  var ic = imageCollection.map(function(image){var t = image.get("system:time_start");return image.toFloat().set("system:time_start",t);});var dimension = ic.size();var identity_mat = ee.Array.identity(dimension);var difference_mat = getDifferenceMatrix(identity_mat,3);var difference_mat_transpose = difference_mat.transpose();var lamda_difference_mat = difference_mat_transpose.multiply(lambda);var res_mat = lamda_difference_mat.matrixMultiply(difference_mat);var hat_matrix = res_mat.add(identity_mat);// 备份原始数据var original = ic;// 获取原始图像属性var properties = ee.List(ic.iterate(function(image, list){return ee.List(list).add(image.toDictionary());},[]));var time = ee.List(ic.iterate(function(image, list){return ee.List(list).add(image.get("system:time_start"));},[]));// 如果数据是合成的// 计算图像在 0 到 100 之间的对比率。首先// 夹在 delta 和 100-delta 之间,其中 delta 是一个很小的正值。if (isCompositional){ic = ic.map(function(image){var t = image.get("system:time_start");var delta = 0.001;var bands = image.bandNames();image = image.clamp(delta,100-delta);image = (ee.Image.constant(100).subtract(image)).divide(image).log().rename(bands);return image.set("system:time_start",t);});}var arrayImage = original.toArray();var coeffimage = ee.Image(hat_matrix);var smoothImage = coeffimage.matrixSolve(arrayImage);var idlist = ee.List(ic.iterate(function(image, list){return ee.List(list).add(image.id());},[]));var bandlist = ee.Image(ic.first()).bandNames();var flatImage = smoothImage.arrayFlatten([idlist,bandlist]);var smoothCollection = ee.ImageCollection(unpack(flatImage, idlist, bandlist));if (isCompositional){smoothCollection = smoothCollection.map(inverseLogRatio);}// 通过添加后缀fitted获得新的乐队名称var newBandNames = bandlist.map(function(band){return ee.String(band).cat("_fitted")});// 重新命名平滑图像中的波段smoothCollection = smoothCollection.map(function(image){return ee.Image(image).rename(newBandNames)});// 一个非常笨的方法,可以flatten谷歌地球引擎生成的 ID,这样就可以将两张图片合并为图表了var dumbimg = arrayImage.arrayFlatten([idlist,bandlist]);var dumbcoll = ee.ImageCollection(unpack(dumbimg,idlist, bandlist));var outCollection = dumbcoll.combine(smoothCollection);var outCollectionProp = outCollection.iterate(function(image,list){var t = image.get("system:time_start")return ee.List(list).add(image.set(properties.get(ee.List(list).size())));},[]);var outCollectionProp = outCollection.iterate(function(image,list){return ee.List(list).add(image.set("system:time_start",time.get(ee.List(list).size())));},[]);var residue_sq = smoothImage.subtract(arrayImage).pow(ee.Image(2)).divide(dimension);var rmse_array = residue_sq.arrayReduce(ee.Reducer.sum(),[0]).pow(ee.Image(1/2));var rmseImage = rmse_array.arrayFlatten([["rmse"],bandlist]);return [ee.ImageCollection.fromImages(outCollectionProp), rmseImage];
}var ndvi =ee.ImageCollection("NOAA/VIIRS/001/VNP13A1").select('NDVI').filterDate("2019-01-01","2019-12-31");
// 去除屏蔽像素
ndvi = ndvi.map(function(img){return img.unmask(ndvi.mean())});var ndvi =  whittakerSmoothing(ndvi)[0];// 添加图表
print(ui.Chart.image.series(ndvi.select(['NDVI', 'NDVI_fitted']), geometry, ee.Reducer.mean(), 500).setSeriesNames(['NDVI', 'NDVI_fitted']).setOptions({title: 'smoothed',lineWidth: 1,pointSize: 3,
}));

结果


http://www.ppmy.cn/news/1518620.html

相关文章

Qt应用的高分辨率适配

背景 工作中需要面对触控大屏的4K分辨率场景&#xff0c;同时也有越来越多人开始使用高分屏&#xff0c;原来多基于1080p分辨率开发的Qt程序无法很好适配更高的分辨率。 没有特意针对高分辨率场景做适配时&#xff0c;Qt应用的表现通常有两种情况&#xff1a; 分辨率高的情况…

波导阵列天线单元学习笔记7 一种用直接金属激光烧结考虑的轻质量,宽带,双圆极化波导腔体阵列

摘要&#xff1a; 提出了一种工作在Ku频段的轻质量&#xff0c;宽带&#xff0c;双圆极化波导腔体阵列。为了获得双正交的线极化&#xff0c;基本的辐射单元是由两个波导馈电的方形腔体。通过恰当地对馈网进行调谐&#xff0c;可以获得对于两个正交极化的等辐同相辐射电场&…

智能指针(RAII)

智能指针&#xff08;RAII&#xff09; 一、内存泄漏1、介绍2、原因3、泄漏的内存类型分类 二、RAII1、介绍2、基本思想3、优点4、实现方式 三、unique_ptr1、介绍2、主要特性3、注意事项4、unique_ptr类5、示例代码6、运行结果7、简单实现 四、shared_ptr1、介绍2、主要特点3、…

如何处理时间序列异常值?理解、检测和替换时间序列中的异常值

异常值的类型 (欢迎来到雲闪世界) 异常值是与正常行为有显著偏差的观察结果。 时间序列可能会因某些异常和非重复事件而出现异常值。这些异常值会影响时间序列分析&#xff0c;并误导从业者得出错误的结论或有缺陷的预测。因此&#xff0c;识别和处理异常值是确保时间序列建模…

【TDesign】如何修改CSS变量

Tdesign的组件想通过style定义样式没效果, 可以通过组件api文档修改, 组件提供了下列 CSS 变量&#xff0c;可用于自定义样式。 比如Cell, https://tdesign.tencent.com/miniprogram/components/cell?tabapi 提供了&#xff1a; –td-cell-left-icon-color 图标颜色 –td-cell…

【Leetcode 2341 】 数组能形成多少数对 —— 去重

给你一个下标从 0 开始的整数数组 nums 。在一步操作中&#xff0c;你可以执行以下步骤&#xff1a; 从 nums 选出 两个 相等的 整数从 nums 中移除这两个整数&#xff0c;形成一个 数对 请你在 nums 上多次执行此操作直到无法继续执行。 返回一个下标从 0 开始、长度为 2 的…

电脑变声器软件哪个好用?最新款实时变声器数据公开!

电脑变声器软件哪个好用&#xff1f;什么场合下需要用到变声器&#xff1f;在派对或朋友聚会中&#xff0c;使用变声器可以模仿各种动物、名人或虚构角色的声音&#xff1b;直播变声搞怪&#xff1b;匿名游戏聊天&#xff1b;电影、动画、电视音效、旁白制作等等&#xff0c;都…

高职院校大数据分析与可视化微服务架构实训室解决方案

一、前言 随着信息技术的飞速发展&#xff0c;大数据已成为推动社会进步与产业升级的关键力量。为了培养适应未来市场需求的高素质技术技能型人才&#xff0c;高职院校纷纷加大对大数据分析与可视化技术的教学投入。唯众&#xff0c;作为国内领先的职业教育解决方案提供商&…

2 Python开发工具:PyCharm的安装和使用

本文是 Python 系列教程第 2 篇&#xff0c;完整系列请查看 Python 专栏。 1 安装 官网下载地址https://www.jetbrains.com.cn/pycharm/&#xff0c;文件比较大&#xff08;约861MB&#xff09;请耐心等待 双击exe安装 安装成功后会有一个30天的试用期。。。本来想放鸡火教程&…

Nginx负载均衡请求队列配置:优化流量管理

在高流量的Web应用场景中&#xff0c;合理地管理进入的请求流量对于保持服务的稳定性和响应性至关重要。Nginx提供了请求队列的配置选项&#xff0c;允许开发者控制进入后端服务器的请求数量。通过配置请求队列&#xff0c;可以在后端服务器达到最大处理能力时&#xff0c;优雅…

005、架构_数据节点

​DN组件总览 ​ DN节点包含进程 dbagent进程:主要提供数据节点高可用、数据导入导出、数据备份恢复、事务一致性、运维类功能、集群的扩缩容、卸数等功能;MySQL进程:主要提供数据一致性、分组管理、快同步复制、高低水位等;

测试岗位应该学什么

以下是测试岗位需要学习的一些关键内容&#xff1a; 1. 测试理论和方法 - 了解不同类型的测试&#xff0c;如功能测试、性能测试、压力测试、安全测试、兼容性测试等。 - 掌握测试策略和测试计划的制定。 2. 编程语言 - 至少熟悉一种编程语言&#xff0c;如 Python、Java…

网络路由介绍,route指令,查询路由表的过程,默认路由

目录 路由 本地主机的路由功能 引入 route指令 查询路由表的过程 介绍 示例 默认路由 注意 路由 本地主机的路由功能 引入 报文经过多个路由器转发至公网,再从公网定位后转发至私网,最终到达目标主机 而报文肯定是要先经过本地主机的 所以本地主机也具有路由功能,也…

django网吧收费管理系统 项目源码26819

摘 要 随着互联网的普及&#xff0c;网吧作为公共互联网接入场所&#xff0c;依旧在许多地区发挥着重要作用。现代网吧不仅仅是提供上网服务的场所&#xff0c;还包括了游戏、社交、休闲等多功能体验。为了提高网吧的服务质量和运营效率&#xff0c;迫切需要一个高效的管理系统…

mysql基础语法——个人笔记

0 前言 以前学习且实践过mysql&#xff0c;但后来用得少&#xff0c;随着岁月更替&#xff0c;对其印象渐浅&#xff0c;所以每次需要用时&#xff0c;都会去再看一眼语法规范&#xff0c;然后才能放心动手操作 然而&#xff0c;在信息爆炸的时代&#xff0c;查语法规范时&am…

ubuntu录屏解决ubuntu下无法播放MP4格式文件的方法

参考 gnome gnome是系统自带的录屏&#xff0c;通过ctrlshiftaltr触发 保存到了视频目录下&#xff0c;webm格式文件。 screencastify 这是一个chrome扩展&#xff0c;&#xff0c;一般不推荐使用 recapp 比gnome自由一些&#xff0c;可以自由屏幕录制。但是无法修改录制…

如何将Dxf文件中的Vertex与相应的polyline关联起来

在处理DXF&#xff08;Drawing Exchange Format&#xff09;文件时&#xff0c;将VERTEX和相应的POLYLINE关联起来是一个常见的需求。这通常涉及解析DXF文件中的几何实体&#xff0c;并确保它们之间的关系正确。以下是一些步骤和示例代码&#xff0c;帮助你实现这种关联&#x…

如果学流式系统你想选一本书,那必须是这本

“如果你关心流式处理和批处理工作的正确性&#xff0c;那么这本书是必读的。它对该主题的讨论是我看到的思考最清晰、最合逻辑的&#xff0c;其思想也被精彩诠释。” ——马丁克莱普曼&#xff08;Martin Kleppmann&#xff09;&#xff0c;剑桥大学 流式系统 如今&#xff0c…

关于mysql的information_schema库表对象

MySQL的information_schema库是一个非常重要的系统数据库&#xff0c;它存储着关于MySQL服务器中所有其他数据库的元数据&#xff08;meta-data&#xff09;。元数据是指关于数据的数据&#xff0c;比如数据库名、表名、列名、数据类型、权限信息等&#xff0c;并不包含实际业务…

Django 后端架构开发:高效测试自动化工具

Django 后端架构开发&#xff1a;高效测试自动化工具 目录 &#x1f6e0; nose&#xff1a;强大的测试框架 &#x1f3ad; faker&#xff1a;模拟数据生成器 &#x1f5a5; PyAutoGUI&#xff1a;跨平台 GUI 自动化测试 &#x1f9ea; coverage&#xff1a;代码覆盖率测量 …