Prześlij opinię
ee.Image.arrayLength
Zadbaj o dobrą organizację dzięki kolekcji
Zapisuj i kategoryzuj treści zgodnie ze swoimi preferencjami.
Zwraca długość tablicy każdego piksela wzdłuż podanej osi.
Wykorzystanie Zwroty Image. arrayLength (axis)
Obraz
Argument Typ Szczegóły to: input
Obraz Obraz wejściowy. axis
Liczba całkowita Oś, wzdłuż której ma być mierzona długość.
Przykłady
Edytor kodu (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
Konfiguracja Pythona
Informacje o interfejsie Python API i używaniu geemap
do interaktywnego programowania znajdziesz na stronie
Środowisko Python .
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 ])
print ( '3-band image:' , img . getInfo ())
# Convert the 3-band image to a 2D array image.
array_img_2d = img . toArray () . toArray ( 1 )
print ( '2D array image (pixel):' , samp_arr_img ( array_img_2d ) . getInfo ())
# [[0],
# [1],
# [2]]
# Get the number of dimensions in each pixel's array.
array_img2d_dim = array_img_2d . arrayDimensions ()
print ( 'N dimensions in array:' , samp_arr_img ( array_img2d_dim ) . getInfo ())
# 2
# Get the array length per dimension per pixel.
array_img_2d_dim_len = array_img_2d . arrayLengths ()
print (
'Array length per dimension:' ,
samp_arr_img ( array_img_2d_dim_len ) . getInfo ()
)
# [3, 1]
# Get the array length for 0-axis (rows).
array_img2d_axis0_len = array_img_2d . arrayLength ( 0 )
print (
'Array length 0-axis (rows):' ,
samp_arr_img ( array_img2d_axis0_len ) . getInfo ()
)
# 3
# Get the array length for 1-axis (columns).
array_img_2d_axis1_len = array_img_2d . arrayLength ( 1 )
print (
'Array length 1-axis (columns):' ,
samp_arr_img ( array_img_2d_axis1_len ) . getInfo ()
)
# 1
Prześlij opinię
O ile nie stwierdzono inaczej, treść tej strony jest objęta licencją Creative Commons – uznanie autorstwa 4.0 , a fragmenty kodu są dostępne na licencji Apache 2.0 . Szczegółowe informacje na ten temat zawierają zasady dotyczące witryny Google Developers . Java jest zastrzeżonym znakiem towarowym firmy Oracle i jej podmiotów stowarzyszonych.
Ostatnia aktualizacja: 2025-07-26 UTC.
Chcesz przekazać coś jeszcze?
[[["Łatwo zrozumieć","easyToUnderstand","thumb-up"],["Rozwiązało to mój problem","solvedMyProblem","thumb-up"],["Inne","otherUp","thumb-up"]],[["Brak potrzebnych mi informacji","missingTheInformationINeed","thumb-down"],["Zbyt skomplikowane / zbyt wiele czynności do wykonania","tooComplicatedTooManySteps","thumb-down"],["Nieaktualne treści","outOfDate","thumb-down"],["Problem z tłumaczeniem","translationIssue","thumb-down"],["Problem z przykładami/kodem","samplesCodeIssue","thumb-down"],["Inne","otherDown","thumb-down"]],["Ostatnia aktualizacja: 2025-07-26 UTC."],[[["`arrayLength()` returns the length of each pixel's array along a specified axis in an image."],["It's used to get the size of array dimensions within images that have been converted to array format."],["This function is crucial for understanding the structure and dimensions of array-based images in Earth Engine."],["By providing the axis as an argument, you can get the length for specific dimensions (like rows or columns) of the array."]]],[]]