GEE错误——Tile error: Arrays must have same lengths on all axes but the cat axis

错误:

我想使用 arrayCat 来联系图像。但是,我总是收到错误“数组必须在除猫轴之外的所有轴上具有相同的长度”。
imgCat: Tile error: Arrays must have same lengths on all axes but the cat axis

 

原始代码:

var modis = ee.ImageCollection("MODIS/061/MOD13Q1"),ext = /* color: #d63000 *//* shown: false *//* displayProperties: [{"type": "rectangle"}] */ee.Geometry.Polygon([[[-97.06328232288361, 37.62180252692555],[-97.06328232288361, 32.220887742314595],[-85.28593857288362, 32.220887742314595],[-85.28593857288362, 37.62180252692555]]], null, false),testPt = /* color: #98ff00 */ee.Geometry.Point([-93.9324058090546, 35.00147792091121]);
var VIs = modis.filterDate('2021','2023').select('NDVI');
Map.centerObject(testPt,16);var arrVIs = VIs.map(function (img){return img.clip(ext).set('system:time_start',img.get('system:time_start'));
}).toBands().toArray().toArray(1);               var mask_NDVI_Higher =  arrVIs.gt(6500);
var zeroImg = ee.Image(0).toArray().toArray(1);// I want to replace the last mask pixel with my own mask. However, it
// failed due to the dimension of the array was varied at pixel scale.
var imgCat = arrVIs.arrayMask(mask_NDVI_Higher).arraySlice(1,0,-1).arrayCat(zeroImg,1);Map.addLayer(VIs,{},'VIs',false);
Map.addLayer(arrVIs,{},'arrVIs',false);
Map.addLayer(mask_NDVI_Higher,{},'mask_NDVI_Higher',false);
Map.addLayer(imgCat,{},'imgCat')

函数:

toArray(axis)
Concatenates pixels from each band into a single array per pixel. The result will be masked if any input bands are masked.

Arguments:
this:image (Image):
Image of bands to convert to an array per pixel. Bands must have scalar pixels, or array pixels with equal dimensionality.

axis (Integer, default: 0):
Axis to concatenate along; must be at least 0 and at most the dimension of the inputs. If the axis equals the dimension of the inputs, the result will have 1 more dimension than the inputs.

Returns: Image

arraySlice(axis, start, end, step)
Creates a subarray by slicing out each position along the given axis from the 'start' (inclusive) to 'end' (exclusive) by increments of 'step'. The result will have as many dimensions as the input, and the same length in all directions except the slicing axis, where the length will be the number of positions from 'start' to 'end' by 'step' that are in range of the input array's length along 'axis'. This means the result can be length 0 along the given axis if start=end, or if the start or end values are entirely out of range.

Arguments:
this:input (Image):
Input array image.

axis (Integer, default: 0):
Axis to subset.

start (Image, default: null):
The coordinate of the first slice (inclusive) along 'axis'. Negative numbers are used to position the start of slicing relative to the end of the array, where -1 starts at the last position on the axis, -2 starts at the next to last position, etc. There must one band for start indices, or one band per 'input' band. If this argument is not set or masked at some pixel, then the slice at that pixel will start at index 0.

end (Image, default: null):
The coordinate (exclusive) at which to stop taking slices. By default this will be the length of the given axis. Negative numbers are used to position the end of slicing relative to the end of the array, where -1 will exclude the last position, -2 will exclude the last two positions, etc. There must be one band for end indices, or one band per 'input' band. If this argument is not set or masked at some pixel, then the slice at that pixel will end just after the last index.

step (Integer, default: 1):
The separation between slices along 'axis'; a slice will be taken at each whole multiple of 'step' from 'start' (inclusive) to 'end' (exclusive). Must be positive.

Returns: Image

arrayMask(mask)
Creates an array image where each array-valued pixel is masked with another array-valued pixel, retaining only the elements where the mask is non-zero. If the mask image has one band it will be applied to all the bands of 'input', otherwise they must have the same number of bands.

Arguments:
this:input (Image):
Array image to mask.

mask (Image):
Array image to mask with.

Returns: Image

arrayCat(image2, axis)
Creates an array image by concatenating each array pixel along the given axis in each band.

Arguments:
this:image1 (Image):
First array image to concatenate.

image2 (Image):
Second array image to concatenate.

axis (Integer):
Axis to concatenate along.

Returns: Image
 

修改后代码:

var modis = ee.ImageCollection("MODIS/061/MOD13Q1"),ext = /* color: #d63000 *//* shown: false *//* displayProperties: [{"type": "rectangle"}] */ee.Geometry.Polygon([[[-97.06328232288361, 37.62180252692555],[-97.06328232288361, 32.220887742314595],[-85.28593857288362, 32.220887742314595],[-85.28593857288362, 37.62180252692555]]], null, false),testPt = /* color: #98ff00 */ee.Geometry.Point([-93.9324058090546, 35.00147792091121]);
var VIs = modis.filterDate('2021','2023').select('NDVI');
Map.centerObject(testPt,16);var arrVIs = VIs.map(function (img){return img.clip(ext).set('system:time_start',img.get('system:time_start'));
}).toBands().toArray().toArray(1);               var mask_NDVI_Higher =  arrVIs.gt(6500);
var zeroImg = ee.Image(0).toArray().toArray(1);Map.addLayer(zeroImg)
Map.addLayer(arrVIs.arraySlice(1,0,-1))// I want to replace the last mask pixel with my own mask. However, it
// failed due to the dimension of the array was varied at pixel scale.
var imgCat = arrVIs.arrayMask(mask_NDVI_Higher).arraySlice(1,0,-1).arrayCat(zeroImg,1);/*Map.addLayer(VIs,{},'VIs',false);
Map.addLayer(arrVIs,{},'arrVIs',false);
Map.addLayer(mask_NDVI_Higher,{},'mask_NDVI_Higher',false);
Map.addLayer(imgCat,{},'imgCat')*/

建议:

在 toArray() 之前做你想做的一些工作,然后加载影像

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.xdnf.cn/news/145263.html

如若内容造成侵权/违法违规/事实不符,请联系一条长河网进行投诉反馈,一经查实,立即删除!

相关文章

SpringBoot——常用注解

Spring Web MVC与Spring Bean注解 Controller/RestController Controller是Component注解的一个延伸,Spring 会自动扫描并配置被该注解标注的类。此注解用于标注Spring MVC的控制器。 Controller RequestMapping("/api/v1") public class UserApiContr…

【计算机视觉】3.传统计算机视觉方法

传统计算机视觉方法 一、大纲图像分割人脸检测行人检测 二、图像分割基于阈值检测的方法基于边缘检测的方法基于区域的分割方法基于图论的分割方法 三、人脸检测四、行人检测五、SVM六、DPM 一、大纲 图像分割 基于阈值、基于边缘 基于区域、基于图论 人脸检测 Haar-like 特征…

IntelliJ IDEA 上 使用git 合并其他分支,合并某一个提交

git 合并其他分支 找到git——>merge… 选择需要合并的分支,不能选和当前分支一样噢 合并,推送即可 合并某个提交到其他分支 点击左下角git——>右键切换分支——>选择需要合并的分支——>选择需要合并的代码——>ch 推送即可

【AI视野·今日NLP 自然语言处理论文速览 第三十八期】Thu, 21 Sep 2023

AI视野今日CS.NLP 自然语言处理论文速览 Thu, 21 Sep 2023 Totally 57 papers 👉上期速览✈更多精彩请移步主页 Daily Computation and Language Papers Chain-of-Verification Reduces Hallucination in Large Language Models Authors Shehzaad Dhuliawala, Mojt…

Leetcode684. 冗余连接

Every day a Leetcode 题目来源:684. 冗余连接 解法1:并查集 因为需要判断是否两个节点被重复连通,所以我们可以使用并查集来解决此类问题。 代码: /** lc appleetcode.cn id684 langcpp** [684] 冗余连接*/// lc codestart…

LeetCode —— 回溯

77. 组合 给定两个整数 n 和 k&#xff0c;返回范围 [1, n] 中所有可能的 k 个数的组合。 示例&#xff1a;输入&#xff1a;n 4, k 2 输出&#xff1a; [ [1,2], [1,3], [1,4], [2,3], [2,4], [3,4]] class Solution {List<List<Integer>> list new…

【100天精通Python】Day67:Python可视化_Matplotlib 绘制动画,2D、3D 动画 示例+代码

1 绘制2D动画&#xff08;animation&#xff09; Matplotlib是一个Python绘图库&#xff0c;它提供了丰富的绘图功能&#xff0c;包括绘制动画。要绘制动画&#xff0c;Matplotlib提供了FuncAnimation类&#xff0c;允许您创建基于函数的动画。下面是一个详细的Matplotlib动画示…

【AI视野·今日CV 计算机视觉论文速览 第257期】Fri, 29 Sep 2023

AI视野今日CS.CV 计算机视觉论文速览 Fri, 29 Sep 2023 Totally 99 papers &#x1f449;上期速览✈更多精彩请移步主页 Daily Computer Vision Papers Learning to Transform for Generalizable Instance-wise Invariance Authors Utkarsh Singhal, Carlos Esteves, Ameesh M…

升级:远程桌面软件玩游戏指南

你有没有遇到过这样的场景&#xff1a;你想玩一款特定的游戏&#xff0c;但却受到设备功能的限制&#xff1f;这就是游戏远程桌面的概念变得非常宝贵的地方。从本质上讲&#xff0c;它允许您远程利用高端游戏计算机的功能&#xff0c;使您能够在自己的设备上玩游戏。 可以考虑…

面向对象之旅:核心理念、设计方法与UML详解(软件设计师笔记)

&#x1f600;前言 面向对象技术是现代软件工程的核心&#xff0c;为软件设计和开发带来了一种强大且有序的方法。通过将现实世界的实体和概念映射到可操作的代码结构&#xff0c;该技术使我们能够更高效、清晰和可靠地创建复杂的软件系统。在本章中&#xff0c;我们将详细介绍…

VS编译器常见的错误

以上问题在编译器中出现可以在编译器中最上面加入&#xff1a; #define_CRT_SECURE_NO_WARNINGS 或者将scanf修改为scanf_s 一定要在最上端&#xff01;&#xff01;&#xff01;最上端&#xff01;&#xff01;&#xff01;最上端加入&#xff01;&#xff01;&#xff01; 虽…

modbusTCP【codesys】

1添加控制器【控制器】&#xff1a; 右击左侧树型菜单【Device】→选择【添加设备】&#xff0c;在弹出对话框中下拉选择【以太网适配器】下的【Ethernet】&#xff0c;最后点击【添加设备】。 注意固件能支持的版本。我的是3.5.17 2添加主站【主站】 2添加从站【从站】 双…

设计模式2、抽象工厂模式 Abstract Factory

解释说明&#xff1a;提供一个创建一系列相关或相互依赖对象的接口&#xff0c;而无需指定他们具体的类。 简言之&#xff0c;一个工厂可以提供创建多种相关产品的接口&#xff0c;而无需像工厂方法一样&#xff0c;为每一个产品都提供一个具体工厂 抽象工厂&#xff08;Abstra…

python:bottle + eel 模仿 mdict 查英汉词典

Eel 是一个轻量的 Python 库&#xff0c;用于制作简单的类似于离线 HTML/JS GUI 应用程序&#xff0c;并具有对 Python 功能和库的完全访问权限。 Eel 托管一个本地 Web 服务器&#xff0c;允许您使用 Python 注释函数&#xff08;annotate functions&#xff09;&#xff0c;…

ThreeJS-3D教学三:平移缩放+物体沿轨迹运动

我们在项目中会有一些这样的需求&#xff0c;我们可视化一个场景&#xff0c;需要俯视、平移、缩放&#xff0c;方便观察场景中的数据或者模型&#xff0c;之所以把这个案例拿出来 1、这是个很实用的需求&#xff0c;我相信很多人会用到 2、我自己认为在实际案例中我们可以学习…

APS手动编译,CLion测试

一、简介 APSI——Asymmetric PSI&#xff1a; 私用集交集&#xff08;PSI&#xff09;是指这样一种功能&#xff0c;即双方都持有一组私用项&#xff0c;可以在不向对方透露任何其他信息的情况下检查他们有哪些共同项。集合大小的上限被假定为公共信息&#xff0c;不受保护。 …

【ARMv8 SIMD和浮点指令编程】NEON 加载指令——如何将数据从内存搬到寄存器(其它指令)?

除了基础的 LDx 指令,还有 LDP、LDR 这些指令,我们也需要关注。 1 LDNP (SIMD&FP) 加载 SIMD&FP 寄存器对,带有非临时提示。该指令从内存加载一对 SIMD&FP 寄存器,向内存系统发出访问是非临时的提示。用于加载的地址是根据基址寄存器值和可选的立即偏移量计算…

CVE-2023-5129 libwebp堆缓冲区溢出漏洞影响分析

漏洞简述 近日苹果、谷歌、Mozilla和微软等公司积极修复了libwebp组件中的缓冲区溢出漏洞&#xff0c;相关时间线如下&#xff1a; 9月7日&#xff0c;苹果发布紧急更新&#xff0c;修复了此前由多伦多大学公民实验室报告的iMessage 0-click 漏洞&#xff0c;漏洞被认为已经被…

【Element-UI】Mock.js,案例首页导航、左侧菜单

一.Mock.js 1、什么是Mock.js Mock.js是一个用于生成模拟数据的JavaScript库。它能够模拟后端API接口&#xff0c;用于前端开发时进行接口调试和测试提高自动化测试效率。使用Mock.js可以快速创建虚拟的数据&#xff0c;并且可以设置数据的类型、格式和规则&#xff0c;从而模…

TouchGFX之动态位图

标准位图会被编译到应用中&#xff0c;因此必须在编译时提供。在运行时间在RAM中创建位图&#xff0c;被称为动态位图。 动态位图的使用与编译到应用中的静态位图相同。 动态位图配置 必须先配置位图缓存&#xff0c;然后才能创建动态位图。 FrontendApplication.hpp#inclu…