Earth Engine a introduit des
niveaux de quota non commerciaux pour protéger les ressources de calcul partagées et garantir des performances fiables pour tous. Les projets non commerciaux utilisent le niveau "Communauté" par défaut, mais vous pouvez modifier le niveau d'un projet à tout moment.
Google uses AI technology to translate content into your preferred language. AI translations can contain errors.
ee.Image.arrayLengths
Restez organisé à l'aide des collections
Enregistrez et classez les contenus selon vos préférences.
Renvoie une image de tableau à une dimension avec la longueur de chaque axe du tableau.
| Utilisation | Renvoie |
|---|
Image.arrayLengths() | Image |
| Argument | Type | Détails |
|---|
ceci : input | Image | Image d'entrée. |
Exemples
Éditeur de code (JavaScript)
// A function to print arrays for a selected pixel in the following examples.
function sampArrImg(arrImg) {
var point = ee.Geometry.Point([-121, 42]);
return arrImg.sample(point, 500).first().get('array');
}
// A 3-band image of constants.
var img = ee.Image([0, 1, 2]);
print('3-band image', img);
// Convert the 3-band image to a 2D array image.
var arrayImg2D = img.toArray().toArray(1);
print('2D array image (pixel)', sampArrImg(arrayImg2D));
// [[0],
// [1],
// [2]]
// Get the number of dimensions in each pixel's array.
var arrayImg2Ddim = arrayImg2D.arrayDimensions();
print('N dimensions in array', sampArrImg(arrayImg2Ddim));
// 2
// Get the array length per dimension per pixel.
var arrayImg2DdimLen = arrayImg2D.arrayLengths();
print('Array length per dimension', sampArrImg(arrayImg2DdimLen));
// [3, 1]
// Get the array length for 0-axis (rows).
var arrayImg2Daxis0Len = arrayImg2D.arrayLength(0);
print('Array length 0-axis (rows)', sampArrImg(arrayImg2Daxis0Len));
// 3
// Get the array length for 1-axis (columns).
var arrayImg2Daxis1Len = arrayImg2D.arrayLength(1);
print('Array length 1-axis (columns)', sampArrImg(arrayImg2Daxis1Len));
// 1
Configuration de Python
Consultez la page
Environnement Python pour en savoir plus sur l'API Python et sur l'utilisation de geemap pour le développement interactif.
import ee
import geemap.core as geemap
Colab (Python)
# A function to print arrays for a selected pixel in the following examples.
def samp_arr_img(arr_img):
point = ee.Geometry.Point([-121, 42])
return arr_img.sample(point, 500).first().get('array')
# A 3-band image of constants.
img = ee.Image([0, 1, 2])
display('3-band image:', img)
# Convert the 3-band image to a 2D array image.
array_img_2d = img.toArray().toArray(1)
display('2D array image (pixel):', samp_arr_img(array_img_2d))
# [[0],
# [1],
# [2]]
# Get the number of dimensions in each pixel's array.
array_img2d_dim = array_img_2d.arrayDimensions()
display('N dimensions in array:', samp_arr_img(array_img2d_dim))
# 2
# Get the array length per dimension per pixel.
array_img_2d_dim_len = array_img_2d.arrayLengths()
display(
'Array length per dimension:',
samp_arr_img(array_img_2d_dim_len)
)
# [3, 1]
# Get the array length for 0-axis (rows).
array_img2d_axis0_len = array_img_2d.arrayLength(0)
display(
'Array length 0-axis (rows):',
samp_arr_img(array_img2d_axis0_len)
)
# 3
# Get the array length for 1-axis (columns).
array_img_2d_axis1_len = array_img_2d.arrayLength(1)
display(
'Array length 1-axis (columns):',
samp_arr_img(array_img_2d_axis1_len)
)
# 1
Sauf indication contraire, le contenu de cette page est régi par une licence Creative Commons Attribution 4.0, et les échantillons de code sont régis par une licence Apache 2.0. Pour en savoir plus, consultez les Règles du site Google Developers. Java est une marque déposée d'Oracle et/ou de ses sociétés affiliées.
Dernière mise à jour le 2025/10/30 (UTC).
[null,null,["Dernière mise à jour le 2025/10/30 (UTC)."],[],[]]