Loading [MathJax]/jax/input/TeX/config.js
前往小程序,Get更优阅读体验!
立即前往
首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
社区首页 >专栏 >GEE错误——Tile error: Arrays must have same lengths on all axes but the cat axis

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

作者头像
此星光明
发布于 2024-02-02 00:47:50
发布于 2024-02-02 00:47:50
12600
代码可运行
举报
运行总次数:0
代码可运行

错误:

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

原始代码:

代码语言:javascript
代码运行次数:0
运行
AI代码解释
复制
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

修改后代码:

代码语言:javascript
代码运行次数:0
运行
AI代码解释
复制
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() 之前做你想做的一些工作,然后加载影像

本文参与 腾讯云自媒体同步曝光计划,分享自作者个人站点/博客。
原始发表:2024-02-01,如有侵权请联系 cloudcommunity@tencent.com 删除

本文分享自 作者个人站点/博客 前往查看

如有侵权,请联系 cloudcommunity@tencent.com 删除。

本文参与 腾讯云自媒体同步曝光计划  ,欢迎热爱写作的你一起参与!

评论
登录后参与评论
暂无评论
推荐阅读
编辑精选文章
换一批
Google Earth Engine(GEE)——提取指定矢量集合中的NDVI值并附时间属性
本教程的主要目的是实现影像转化为数组,然后我们需要直到其转化为的数组的轴,然后根据轴的信息进行切片,切片后完成时间属性的标准转化,这里一定要对影像结果提取完成后再对矢量集合进行操作,最后就可以提取指定的属性信息。
此星光明
2024/02/02
5120
Google Earth Engine(GEE)——容易犯的错误5(fastDistanceTransform()、reduceNeighborhood() 和iterate())
对于某些卷积运算,fastDistanceTransform()可能比reduceNeighborhood()或更有效convolve()。例如,要对二进制输入进行腐蚀和/或膨胀:
此星光明
2024/02/02
2100
Google Earth Engine(GEE)——容易犯的错误5(fastDistanceTransform()、reduceNeighborhood() 和iterate())
【GEE】5、遥感影像预处理【GEE栅格预处理】
什么是预处理? 您将在 Google 地球引擎 (GEE) 中找到的大部分数据都经过了一定程度的预处理。这涉及几种不同的质量控制方法,以确保栅格集合内的最高准确性和一致性。根据收集的不同,可能有各种可用的预处理级别,了解差异以将遥感数据成功整合到生态研究中非常重要。在 GEE 中提供数据之前,出版商一致解决了图像产品的三个常见错误来源:大气(即空气化学)、地形(即高程)和几何(即像素一致性)。
Twcat_tree
2023/11/07
8530
【GEE】5、遥感影像预处理【GEE栅格预处理】
Google Earth Engine(GEE)——当加载图表的时候出现错误No features contain non-null values of “system:time_start“.
Error generating chart: The image collection is empty.
此星光明
2024/02/02
1880
Google Earth Engine(GEE)——当加载图表的时候出现错误No features contain non-null values of “system:time_start“.
GEE代码条带问题——sentinel-1接缝处理的问题
我有兴趣确定 NDVI 损失最大的年份。我创建了一个函数来收集所有陆地卫星图像并应用预处理。当我导出结果以识别 NDVI 损失最大年份时,生成的数据产品与陆地卫星场景足迹有可怕的接缝线。造成这种情况的原因是什么以及如何调整代码?
此星光明
2024/03/08
2630
GEE代码条带问题——sentinel-1接缝处理的问题
Google Earth Engine(GEE)——R 语言 Google 地球引擎20个基本案例分析
Earth Engine 服务器对象是具有以ee(例如eeImage、eeReducer)开头的构造函数的对象,并且此类对象上的任何方法都是服务器函数。任何不是以这种方式构造的对象都是客户端对象。客户端对象可能来自 R Earth Engine 客户端(例如 Map)或 R 语言(例如 date、data.frame、c()、list())。
此星光明
2024/02/02
4360
Google Earth Engine(GEE)——R 语言 Google 地球引擎20个基本案例分析
GEE非参数趋势分析(Mk-Sen)
趋势分析是寻找感兴趣的东西正在增加的地方,或者 减少多少。更具体地说,本教程演示了 使用非参数 Mann-Kendall 检测影像中的单调趋势 测试是否存在增加或减少的趋势以及 Sen 的斜率 量化趋势的幅度(如果存在)。本教程还显示 估计 Mann-Kendall 检验统计量的方差,Mann Kendall 检验统计量是 检验是否存在任何趋势,以及统计量的 P 值(假设 正态分布)。 重要提示:此处介绍的方法 适用于评估单调趋势(即没有季节性的数据) 在离散数据中(即非浮点)。此外,如果应用 本教程中的方法对新数据(即地区、时间范围、来源)可以 需要调整和可视化参数以适应 特别的结果。
Twcat_tree
2024/04/15
5770
GEE非参数趋势分析(Mk-Sen)
GEE 案例:如何利用Landsat 8 数据和NDWI指数来计算指定区域的水域面积
这里我们进行影像的水域面积计算,这里出了影像预处理后,最主要的过程就是如何进行像素面积计算,另外,如何利用统计函数来进行sum来统计整个像素内的面积是多少。
此星光明
2024/09/13
4230
GEE 案例:如何利用Landsat 8 数据和NDWI指数来计算指定区域的水域面积
GEE 案例:利用sentinel-2数据计算的NDVI指数对比植被退化情况
NDVI(Normalized Difference Vegetation Index,归一化植被指数)是通过计算红外波段和可见光波段的反射值之间的差异来评估植被的状况。利用NDVI指数可以监测植被的退化情况。
此星光明
2024/09/19
8440
GEE 案例:利用sentinel-2数据计算的NDVI指数对比植被退化情况
【GEE】基于PCA的LANDSAT 8计算遥感生态指数(RSEI)
Twcat_tree
2024/04/08
5050
【GEE】基于PCA的LANDSAT 8计算遥感生态指数(RSEI)
Google Earth Engine:对NDVI进行惠特克平滑算法进行长时序分析
惠特克(GEE)平滑算法是一种用于时间序列预测的统计方法,特别适用于非线性、非平稳和非高斯的数据。该算法基于广义估计方程,通过最小化残差的平方和来拟合数据并找到最佳的平滑曲线。
此星光明
2024/09/02
1700
Google Earth Engine:对NDVI进行惠特克平滑算法进行长时序分析
GEE 案例:利用2001-2024年的MODIS数据长时序ndvi指数归一化后的结果分析
利用2001-2024年的MODIS数据长时序ndvi指数归一化后的结果分析,并加载时序图。
此星光明
2024/09/18
3800
GEE 案例:利用2001-2024年的MODIS数据长时序ndvi指数归一化后的结果分析
GEE代码实例教程详解:植被状况指数(VCI)与干旱监测
在本篇博客中,我们将使用Google Earth Engine (GEE) 进行植被状况指数(Vegetation Condition Index, VCI)的计算和干旱监测。通过MODIS NDVI数据,我们可以评估2001年至2024年间的植被状况和干旱等级。
Twcat_tree
2024/07/09
4560
GEE教程:利用sentinel-2数据进行ndwi和ndci指数的计算和下载
NDWI(Normalized Difference Water Index,归一化差异水体指数)和NDCI(Normalized Difference Chlorophyll Index,归一化差异叶绿素指数)都是一种利用遥感影像数据来评估特定地物或地表类型的指数。
此星光明
2024/09/25
3270
GEE教程:利用sentinel-2数据进行ndwi和ndci指数的计算和下载
Google Earth Engine(GEE)——哨兵数据中隐藏的秘密(卫星影像拍到的如来神掌)
本来尝试着用用分辨率较为粗的modis影像查看,但是因为影像分辨率太粗了,所以只能放弃,不错具体加载的图,也在下面:
此星光明
2024/02/02
1930
Google Earth Engine(GEE)——哨兵数据中隐藏的秘密(卫星影像拍到的如来神掌)
Google Earth Engine(GEE)——Landsat 8TI/TOA/SR影像对比分析区别和去云即NDVI计算
什么是预处理? 您将在 Google Earth Engine (GEE) 中找到的大部分数据都经过一定程度的预处理。这涉及多种不同的质量控制方法,以确保栅格集合中的最高级别的准确性和一致性。根据收集的不同,可能有多种可用的预处理级别,了解差异以成功地将遥感数据集成到生态研究中是很重要的。在 GEE 中提供数据之前,出版商一致解决图像产品的三个常见错误来源:大气(即空气化学)、地形(即高程)和几何(即像素一致性)。
此星光明
2024/02/02
7360
Google Earth Engine(GEE)——Landsat 8TI/TOA/SR影像对比分析区别和去云即NDVI计算
Google Earth Engine(GEE)——ndvi.gt is not a function
我试图通过屏蔽值的上下 10 个百分位数来消除计算出的 NDVI 数据集中的异常值,但我在第 398 行中不断收到错误消息,显示第 398 行: ndvi.gt不是函数。 我怎样才能解决这个问题?
此星光明
2024/02/02
1810
Google Earth Engine(GEE)——ndvi.gt is not a function
Google Earth Engine(GEE)——影像分类中出现的错误(Classifier confusionMatrix: Property ‘type‘ of feature ‘000000)
I'm trying to use a classifier to classify the land use of Landsat images, but when I use the function which is "classifier. conflusionMatrix", I get an error as follows: Classifier confusionMatrix: Property 'type' of feature '00000000000000000014_ 0' is missing. (Error code: 3). I don't know how to correct it. I really need your help to solve this problem. By the way, I finally remembered to share the assets.
此星光明
2024/02/02
2330
Google Earth Engine(GEE)——影像分类中出现的错误(Classifier confusionMatrix: Property ‘type‘ of feature ‘000000)
GEE错误——Layer error: Image.connectedPixelCount: Segment size calculation on floating point bands is n
我正在编写一段代码,用于检测/计算图像中烧焦区域的斑块。我以为使用 GEE 中的 connectedPixelCount() 函数可以帮助我完成这项工作。然而,后者似乎对合成图像不起作用。有没有办法让它将合成图像视为典型的单层图像?(如果有用于合成图像的替代函数,也能解决我的问题)。
此星光明
2024/02/02
1810
GEE错误——Layer error: Image.connectedPixelCount: Segment size calculation on floating point bands is n
GEE实现图像随机森林分类
对图像进行土地利用分类,因此下面是监督分类的流程以及代码案例。 1.首先分类最开始应该建立样本数据集,在这里我分了四类,然后就开始自己的采样,设立好分类后,对目标进行分类。
Twcat_tree
2023/01/30
1.7K0
推荐阅读
Google Earth Engine(GEE)——提取指定矢量集合中的NDVI值并附时间属性
5120
Google Earth Engine(GEE)——容易犯的错误5(fastDistanceTransform()、reduceNeighborhood() 和iterate())
2100
【GEE】5、遥感影像预处理【GEE栅格预处理】
8530
Google Earth Engine(GEE)——当加载图表的时候出现错误No features contain non-null values of “system:time_start“.
1880
GEE代码条带问题——sentinel-1接缝处理的问题
2630
Google Earth Engine(GEE)——R 语言 Google 地球引擎20个基本案例分析
4360
GEE非参数趋势分析(Mk-Sen)
5770
GEE 案例:如何利用Landsat 8 数据和NDWI指数来计算指定区域的水域面积
4230
GEE 案例:利用sentinel-2数据计算的NDVI指数对比植被退化情况
8440
【GEE】基于PCA的LANDSAT 8计算遥感生态指数(RSEI)
5050
Google Earth Engine:对NDVI进行惠特克平滑算法进行长时序分析
1700
GEE 案例:利用2001-2024年的MODIS数据长时序ndvi指数归一化后的结果分析
3800
GEE代码实例教程详解:植被状况指数(VCI)与干旱监测
4560
GEE教程:利用sentinel-2数据进行ndwi和ndci指数的计算和下载
3270
Google Earth Engine(GEE)——哨兵数据中隐藏的秘密(卫星影像拍到的如来神掌)
1930
Google Earth Engine(GEE)——Landsat 8TI/TOA/SR影像对比分析区别和去云即NDVI计算
7360
Google Earth Engine(GEE)——ndvi.gt is not a function
1810
Google Earth Engine(GEE)——影像分类中出现的错误(Classifier confusionMatrix: Property ‘type‘ of feature ‘000000)
2330
GEE错误——Layer error: Image.connectedPixelCount: Segment size calculation on floating point bands is n
1810
GEE实现图像随机森林分类
1.7K0
相关推荐
Google Earth Engine(GEE)——提取指定矢量集合中的NDVI值并附时间属性
更多 >
领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档
本文部分代码块支持一键运行,欢迎体验
本文部分代码块支持一键运行,欢迎体验