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

错误:

我想使用 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() 之前做你想做的一些工作,然后加载影像

相关文章
|
机器学习/深度学习 人工智能 测试技术
11种开源即插即用模块汇总 !!(附论文和代码)
11种开源即插即用模块汇总 !!(附论文和代码)
1299 1
|
定位技术
GEE(CCDC-3)——根据CCDC segment分割后的影像进行地类变化统计和绘制土地覆被变化地图
GEE(CCDC-3)——根据CCDC segment分割后的影像进行地类变化统计和绘制土地覆被变化地图
796 0
|
并行计算 异构计算
下载和安装CUDA和Cudnn(图文详解)
下载和安装CUDA和Cudnn(图文详解)
2028 0
下载和安装CUDA和Cudnn(图文详解)
|
数据采集 ice Sentinel
Google Earth Engine(GEE)——sentinel2数据介绍
Google Earth Engine(GEE)——sentinel2数据介绍
1814 0
Google Earth Engine(GEE)——sentinel2数据介绍
|
10月前
|
机器学习/深度学习 文字识别 算法
OCR与语义分割技术详解:法小师如何智能解析纸质合同
语义分割结合OCR,实现文档像素级理解,精准识别标题、表格、签名等元素,破解传统OCR无法解析版面的难题。通过深度学习与多模态融合,将复杂合同转化为可编辑、可分析的结构化数据,助力智能文档处理迈向“机器认知”新阶段。(238字)
ArcMAP对遥感影像进行波段提取的3种方法
ArcMAP对遥感影像进行波段提取的3种方法
5330 0
|
传感器 编解码 数据可视化
GEE数据集:2017-2024年全球多源遥感数据融合的全新10米数据集(无量纲)Satellite Embedding V1
Google Satellite Embedding 数据集提供全球10米分辨率的64维嵌入向量,编码地表条件的时间轨迹,适用于变化检测与地理分析。
957 0
|
机器学习/深度学习 计算机视觉
YOLOv11改进策略【卷积层】| 引入注意力卷积模块RFAConv,关注感受野空间特征 助力yolov11精度提升
YOLOv11改进策略【卷积层】| 引入注意力卷积模块RFAConv,关注感受野空间特征 助力yolov11精度提升
480 0
YOLOv11改进策略【卷积层】| 引入注意力卷积模块RFAConv,关注感受野空间特征 助力yolov11精度提升
|
机器学习/深度学习 并行计算 异构计算
WINDOWS安装eiseg遇到的问题和解决方法
通过本文的详细步骤和问题解决方法,希望能帮助你顺利在 Windows 系统上安装和运行 EISeg。
1062 2
|
机器学习/深度学习 数据采集 算法
监督学习工作流程:从数据准备到模型部署
本文详细介绍了监督学习的工作流程,涵盖数据准备、模型选择、训练、评估与优化、部署等关键步骤,并结合具体代码示例,帮助读者全面掌握监督学习在实际项目中的应用方法。从数据收集、清洗到特征工程,再到模型训练与评估,最后部署模型,每个环节都提供了详细的指导和实践建议。适合初学者和有一定基础的读者深入学习。
1265 2