GEE錯誤——PCA系數變換的時候出現的錯誤

目錄

錯誤提示1

錯誤提示2

原始的教程鏈接:

錯誤代碼

修正后的代碼?

結果


錯誤提示1

這個是因為原始GEE教程中給的讓我們填入需要進行計算的波段名稱,而且是以list的形式傳入。

錯誤提示2

這里我們雖然傳入了正確的波段名稱,但是發現要求的list要多一個中括號,所以我們再次修改代碼。

原始的教程鏈接:

https://developers.google.com/earth-engine/guides/arrays_eigen_analysis#code-editor-javascript

錯誤代碼

var roi = /* color: #d63000 *//* displayProperties: [{"type": "rectangle"}] */ee.Geometry.Polygon([[[-80.39442194432449, 25.89616042988596],[-80.39442194432449, 25.698332029213574],[-80.21864069432449, 25.698332029213574],[-80.21864069432449, 25.89616042988596]]], null, false);var getPrincipalComponents = function(centered, scale, region) {// Collapse the bands of the image into a 1D array per pixel.var arrays = centered.toArray();// Compute the covariance of the bands within the region.var covar = arrays.reduceRegion({reducer: ee.Reducer.centeredCovariance(),geometry: region,scale: scale,maxPixels: 1e9});// Get the 'array' covariance result and cast to an array.// This represents the band-to-band covariance within the region.var covarArray = ee.Array(covar.get('array'));// Perform an eigen analysis and slice apart the values and vectors.var eigens = covarArray.eigen();// This is a P-length vector of Eigenvalues.var eigenValues = eigens.slice(1, 0, 1);// This is a PxP matrix with eigenvectors in rows.var eigenVectors = eigens.slice(1, 1);// Convert the array image to 2D arrays for matrix computations.var arrayImage = arrays.toArray(1);// Left multiply the image array by the matrix of eigenvectors.var principalComponents = ee.Image(eigenVectors).matrixMultiply(arrayImage);// Turn the square roots of the Eigenvalues into a P-band image.var sdImage = ee.Image(eigenValues.sqrt()).arrayProject([0]).arrayFlatten([getNewBandNames('sd')]);// Turn the PCs into a P-band image, normalized by SD.return principalComponents// Throw out an an unneeded dimension, [[]] -> []..arrayProject([0])// Make the one band array image a multi-band image, [] -> image..arrayFlatten([getNewBandNames('pc')])// Normalize the PCs by their SDs..divide(sdImage);
};var image = ee.ImageCollection('LANDSAT/LC08/C02/T1_TOA').filterBounds(roi).filterDate('2020-01-01','2020-03-01').mosaic().select(['B2', 'B3', 'B4', 'B5', 'B6', 'B7'])var centered = image.subtract(image.reduceRegion({'reducer': ee.Reducer.mean(), 'geometry': roi, 'scale': 30, 'maxPixels': 1e13}))var principal_components = getPrincipalComponents(image, 30, roi)print('principal_components',principal_components)

修正后的代碼?

var roi = /* color: #d63000 *//* displayProperties: [{"type": "rectangle"}] */ee.Geometry.Polygon([[[-80.39442194432449, 25.89616042988596],[-80.39442194432449, 25.698332029213574],[-80.21864069432449, 25.698332029213574],[-80.21864069432449, 25.89616042988596]]], null, false);var getPrincipalComponents = function(centered, scale, region) {// Collapse the bands of the image into a 1D array per pixel.var arrays = centered.toArray();// Compute the covariance of the bands within the region.var covar = arrays.reduceRegion({reducer: ee.Reducer.centeredCovariance(),geometry: region,scale: scale,maxPixels: 1e9});// Get the 'array' covariance result and cast to an array.// This represents the band-to-band covariance within the region.var covarArray = ee.Array(covar.get('array'));// Perform an eigen analysis and slice apart the values and vectors.var eigens = covarArray.eigen();// This is a P-length vector of Eigenvalues.var eigenValues = eigens.slice(1, 0, 1);// This is a PxP matrix with eigenvectors in rows.var eigenVectors = eigens.slice(1, 1);// Convert the array image to 2D arrays for matrix computations.var arrayImage = arrays.toArray(1);// Left multiply the image array by the matrix of eigenvectors.var principalComponents = ee.Image(eigenVectors).matrixMultiply(arrayImage);// Turn the square roots of the Eigenvalues into a P-band image.var sdImage = ee.Image(eigenValues.sqrt()).arrayProject([0]).arrayFlatten([['B2_sd', 'B3_sd', 'B4_sd', 'B5_sd', 'B6_sd', 'B7_sd']]);// Turn the PCs into a P-band image, normalized by SD.return principalComponents// Throw out an an unneeded dimension, [[]] -> []..arrayProject([0])// Make the one band array image a multi-band image, [] -> image..arrayFlatten([['B2_pc', 'B3_pc', 'B4_pc', 'B5_pc', 'B6_pc', 'B7_pc']])// Normalize the PCs by their SDs..divide(sdImage);
};var image = ee.ImageCollection('LANDSAT/LC08/C02/T1_TOA').filterBounds(roi).filterDate('2020-01-01','2020-03-01').mosaic().select(['B2', 'B3', 'B4', 'B5', 'B6', 'B7'])var centered = image.subtract(image.reduceRegion({'reducer': ee.Reducer.mean(), 'geometry': roi, 'scale': 30, 'maxPixels': 1e13}))var principal_components = getPrincipalComponents(image, 30, roi)print('principal_components',principal_components)

結果

本文來自互聯網用戶投稿,該文觀點僅代表作者本人,不代表本站立場。本站僅提供信息存儲空間服務,不擁有所有權,不承擔相關法律責任。
如若轉載,請注明出處:http://www.pswp.cn/web/64123.shtml
繁體地址,請注明出處:http://hk.pswp.cn/web/64123.shtml
英文地址,請注明出處:http://en.pswp.cn/web/64123.shtml

如若內容造成侵權/違法違規/事實不符,請聯系多彩編程網進行投訴反饋email:809451989@qq.com,一經查實,立即刪除!

相關文章

C#代碼實現把中文錄音文件(.mp3 .wav)轉為文本文字內容

我們有一個中文錄音文件.mp3格式或者是.wav格式,如果我們想要提取錄音文件中的文字內容,我們可以采用以下方法,不需要使用Azure Speech API 密鑰注冊通過離線的方式實現。 1.首先我們先在NuGet中下載兩個包 NAudio 2.2.1、Whisper.net 1.7.3…

【py腳本+logstash+es實現自動化檢測工具】

概述 有時候,我們會遇到需要查看服務器的網絡連接或者內存或者其他指標是否有超時,但是每次需要登錄到服務器查看會很不方便,所以我們可以設置一個自動腳本化工具自動幫助我們查看,下面我做了一個demo在windows上面。 一、py腳本 import s…

計算機操作系統與安全復習筆記

1 緒論 操作系統目標: 方便性; 有效性; 可擴充性; 開放性. 作用: 用戶與計算機硬件系統之間的接口; 計算機資源的管理者; 實現了對計算機資源的抽象; 計算機工作流程的組織者. 多道程序設計: 內存中同時存放若干個作業, 使其共享系統資源且同時運行; 單處理機環境下宏觀上并行…

qt5.12.11+msvc編譯器編譯qoci驅動

1.之前編譯過minGW編譯器編譯qoci驅動,很順利就完成了,文章地址:minGW編譯qoci驅動詳解,今天按照之前的步驟使用msvc編譯器進行編譯,直接就報錯了: 查了些資料,發現兩個編譯器在編譯時,pro文件中引用的庫不一樣,下面是msvc編譯器引用的庫,其中編譯引用的庫我這里安裝…

Java爬蟲實戰:深度解析VIP商品詳情獲取技術

在數字化時代,數據的價值不言而喻。對于電商平臺而言,掌握VIP商品的詳細信息是提升服務質量、優化用戶體驗的關鍵。然而,這些信息往往被復雜的網頁結構和反爬蟲策略所保護。本文將帶你深入了解如何使用Java編寫爬蟲,以安全、高效地…

校史館云展廳適合遠程教學嗎?

隨著信息技術的飛速發展,遠程教學已經成為教育領域的一個重要趨勢。 校史館作為學校文化傳承的重要場所,承載著豐富的歷史信息和教育資源。 那么,將校史館搬到云端,構建云展廳,是否適合遠程教學呢? 下面…

一些elasticsearch重要概念與配置參數

ES 是在 lucene 的基礎上進行研發的,隱藏了 lucene 的復雜性,提供簡單易用的 RESTful Api接口。ES 的分片相當于 lucene 的索引。 Node 節點的幾種部署實例 實例一: 只用于數據存儲和數據查詢,降低其資源消耗率 node.master: false node.da…

交換機與路由器的區別

交換機和路由器是網絡中的兩種關鍵設備,它們各自承擔不同的功能,主要區別體現在以下幾個方面: 一、工作層次與功能 交換機: 工作層次:交換機主要工作在OSI模型的第二層,即數據鏈路層。 功能:交…

Go Energy 跨平臺框架 v2.5.1 發布

Energy 框架 是Go語言基于CEF 和 LCL 開發的跨平臺 GUI 框架, 具體豐富的系統原生 UI 控件集, 豐富的 CEF 功能 API,簡化且不失功能的 CEF 功能 API 使用。 特性? 特性描述跨平臺支持 Windows, macOS, Linux簡單Go語言的簡單特性,使用簡單…

宏轉錄組+HiFi宏基因組:揭示厭氧消化中的碳流和能量轉換

厭氧消化是一種重要的工程生物技術,對有機廢物的資源回收和可再生能源的生產起著關鍵作用。然而,由于對未培養的厭氧菌及其適應環境變化的能力了解有限,這限制了該技術的優化和生物氣生產的可持續性。今天小編帶大家看一篇發表在《Microbiome…

PVE虛擬化平臺之開啟溫度顯示方法

PVE虛擬化平臺之開啟溫度顯示方法 一、PVE平臺介紹1.1 PVE簡介1.2 PVE特點1.3 PVE主要使用場景二、本次實踐介紹2.1 環境介紹2.2 本次實踐簡介2.3 檢查PVE狀態三、pvetools介紹3.1 pvetool簡介3.2 功能概覽四、使用pvetools工具4.1 下載pvetools項目4.2 執行腳本五、一鍵安裝腳…

C++中的命名規范:定義、用途與最佳實踐

C中的命名規范:定義、用途與最佳實踐 在軟件開發中,命名規范(Naming Conventions)是指為變量、函數、類、命名空間等代碼實體統一制定的命名規則和風格。對于C編程語言而言,遵循良好的命名規范不僅能夠提升代碼的可讀…

SpringCloud 運用(2)—— 跨服務調度

上一篇:SpringCloud 入門(1)—— nacos 注冊中心-CSDN博客 1.RestTemplate 跨服務請求 RestTemplate 是 Spring 框架中的一個同步客戶端,用于與 HTTP 服務進行交互。它簡化了與 HTTP 服務器通信的過程,并且提供了對多…

解決Springboot整合Shiro自定義SessionDAO+Redis管理會話,登錄后不跳轉首頁

解決Springboot整合Shiro自定義SessionDAORedis管理會話,登錄后不跳轉首頁 問題發現問題解決 問題發現 在Shiro框架中,SessionDAO的默認實現是MemorySessionDAO。它內部維護了一個ConcurrentMap來保存session數據,即將session數據緩存在內存…

java歷史版本信息

Java是由Sun Microsystems(后被Oracle公司收購)于1995年推出的面向對象程序設計語言和Java平臺的總稱。到目前為止,Java已經發布了多個版本,以下是Java的主要版本及其發布時間。 一般來說,LTS版本(長期支持…

windows nmake 安裝openssl

windows nmake 編譯和安裝 openssl 本文提供了在Windows環境下安裝OpenSSL的詳細步驟,包括下載Perl、NASM和VisualStudio,配置環境變量,使用PerlConfigure設置平臺,通過nmake進行編譯、測試和安裝。整個過程涉及32位和64位版本的選…

Spring Boot應用開發實戰:從入門到精通

一、Spring Boot 簡介 1.1 什么是 Spring Boot? Spring Boot 是一個開源框架,旨在簡化新 Spring 應用的初始搭建以及開發過程。它構建在 Spring 框架之上,利用了 Spring 的核心特性,如依賴注入(Dependency Injection&…

一、Hadoop概述

文章目錄 一、Hadoop是什么二、Hadoop發展歷史三、Hadoop三大發行版本1. Apache Hadoop2. Cloudera Hadoop3. Hortonworks Hadoop四、Hadoop優勢1. 高可靠性2. 高擴展性3. 高效性4. 高容錯性五、Hadoop 組成1. Hadoop1.x、2.x、3.x區別2. HDFS 架構概述3. YARN 架構概述4. MapR…

python版本的Selenium的下載及chrome環境搭建和簡單使用

針對Python版本的Selenium下載及Chrome環境搭建和使用,以下將詳細闡述具體步驟: 一、Python版本的Selenium下載 安裝Python環境: 確保系統上已經安裝了Python 3.8及以上版本。可以從[Python官方網站]下載并安裝最新版本的Python,…

vue---- H5頁面 pdf,docx,excel文件預覽下載功能

vue---- H5頁面 pdf,docx,excel文件預覽&&下載功能 pdf,docx,excel文件預覽&&下載適用于vue2和vue3,示例為vue3 1.npm下載這些文件的插件(選擇自己需要預覽的進行下載) 安裝pd…