공지사항 :
2025년 4월 15일 전에 Earth Engine 사용을 위해 등록된 모든 비상업용 프로젝트는 Earth Engine 액세스를 유지하기 위해
비상업용 자격 요건을 인증 해야 합니다.
의견 보내기
ee.Image.arrayReduce
컬렉션을 사용해 정리하기
내 환경설정을 기준으로 콘텐츠를 저장하고 분류하세요.
각 배열 픽셀의 요소를 줄입니다.
사용 반환 값 Image. arrayReduce (reducer, axes, fieldAxis )
이미지
인수 유형 세부정보 다음과 같은 경우: input
이미지 입력 이미지입니다. reducer
감소기 적용할 리듀서입니다. axes
목록 각 픽셀에서 축소할 배열 축의 목록입니다. 출력의 길이는 이러한 모든 축에서 1입니다. fieldAxis
정수, 기본값: null 리듀서의 입력 및 출력 필드의 축입니다. 리듀서에 입력 또는 출력이 여러 개인 경우에만 필요합니다.
예
코드 편집기 (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' );
}
// Create a 1D array image with length 6.
var arrayImg1D = ee . Image ([ 0 , 1 , 2 , 3 , 4 , 5 ]). toArray ();
print ( '1D array image (pixel)' , sampArrImg ( arrayImg1D ));
// [0, 1, 2, 3, 4, 5]
// Sum the elements in the 1D array image.
var arrayImg1Dsum = arrayImg1D . arrayReduce ( ee . Reducer . sum (), [ 0 ]);
print ( '1D array image sum (pixel)' , sampArrImg ( arrayImg1Dsum ));
// [15]
// Create a 2D array image with 2 rows and 3 columns.
var arrayImg2D = arrayImg1D . arrayReshape ( ee . Image ([ 2 , 3 ]). toArray (), 2 );
print ( '2D array image (pixel)' , sampArrImg ( arrayImg2D ));
// [[0, 1, 2],
// [3, 4, 5]]
// Sum 2D array image along 0-axis.
var arrayImg2DsumRow = arrayImg2D . arrayReduce ( ee . Reducer . sum (), [ 0 ]);
print ( '2D array image sum rows (pixel)' , sampArrImg ( arrayImg2DsumRow ));
// [[3, 5, 7]]
// Sum 2D array image along 1-axis.
var arrayImg2DsumCol = arrayImg2D . arrayReduce ( ee . Reducer . sum (), [ 1 ]);
print ( '2D array image sum columns (pixel)' , sampArrImg ( arrayImg2DsumCol ));
// [[3],
// [12]]
// Sum 2D array image 0-axis and 1-axis.
var arrayImg2DsumRowCol = arrayImg2D . arrayReduce ( ee . Reducer . sum (), [ 0 , 1 ]);
print ( '2D array image sum columns (pixel)' , sampArrImg ( arrayImg2DsumRowCol ));
// [[15]]
// For reducers that provide several outputs (like minMax and percentile),
// you need to ensure you have a dimension to hold the results. For instance,
// if you want minMax for a 1D array, add a second dimension.
var arrayImg1Dto2D = arrayImg1D . toArray ( 1 );
print ( '1D array image to 2D' , sampArrImg ( arrayImg1Dto2D ));
// [[0],
// [1],
// [2],
// [3],
// [4],
// [5]]
// Calculate min and max for 2D array, use the fieldAxis parameter.
var minMax1D = arrayImg1Dto2D . arrayReduce ( ee . Reducer . minMax (), [ 0 ], 1 );
print ( '1D array image minMax (pixel)' , sampArrImg ( minMax1D ));
// [[0, 5]]
// If your array image is 2D and you want min and max, add a third dimension.
var arrayImg2Dto3D = arrayImg2D . toArray ( 2 );
print ( '2D array image to 3D' , sampArrImg ( arrayImg2Dto3D ));
// [[[0], [1], [2]],
// [[3], [4], [5]]]
// Calculate min and max along the 0-axis, store results in 2-axis.
var minMax2D = arrayImg2Dto3D . arrayReduce ( ee . Reducer . minMax (), [ 0 ], 2 );
print ( '2D array image minMax (pixel)' , sampArrImg ( minMax2D ));
// [[[0, 3],
// [1, 4],
// [2, 5]]]
Python 설정
Python API 및 geemap
를 사용한 대화형 개발에 관한 자세한 내용은
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' )
# Create a 1D array image with length 6.
array_img_1d = ee . Image ([ 0 , 1 , 2 , 3 , 4 , 5 ]) . toArray ()
print ( '1D array image (pixel):' , samp_arr_img ( array_img_1d ) . getInfo ())
# [0, 1, 2, 3, 4, 5]
# Sum the elements in the 1D array image.
array_img_1d_sum = array_img_1d . arrayReduce ( ee . Reducer . sum (), [ 0 ])
print ( '1D array image sum (pixel):' , samp_arr_img ( array_img_1d_sum ) . getInfo ())
# [15]
# Create a 2D array image with 2 rows and 3 columns.
array_img_2d = array_img_1d . arrayReshape ( ee . Image ([ 2 , 3 ]) . toArray (), 2 )
print ( '2D array image (pixel):' , samp_arr_img ( array_img_2d ) . getInfo ())
# [[0, 1, 2],
# [3, 4, 5]]
# Sum 2D array image along 0-axis.
array_img_2d_sum_row = array_img_2d . arrayReduce ( ee . Reducer . sum (), [ 0 ])
print (
'2D array image sum rows (pixel):' ,
samp_arr_img ( array_img_2d_sum_row ) . getInfo ()
)
# [[3, 5, 7]]
# Sum 2D array image along 1-axis.
array_img_2d_sum_col = array_img_2d . arrayReduce ( ee . Reducer . sum (), [ 1 ])
print (
'2D array image sum columns (pixel):' ,
samp_arr_img ( array_img_2d_sum_col ) . getInfo ()
)
# [[3],
# [12]]
# Sum 2D array image 0-axis and 1-axis.
array_img_2d_sum_row_col = array_img_2d . arrayReduce ( ee . Reducer . sum (), [ 0 , 1 ])
print (
'2D array image sum columns (pixel):' ,
samp_arr_img ( array_img_2d_sum_row_col ) . getInfo ()
)
# [[15]]
# For reducers that provide several outputs (like minMax and percentile),
# you need to ensure you have a dimension to hold the results. For instance,
# if you want minMax for a 1D array, add a second dimension.
array_img_1d_to_2d = array_img_1d . toArray ( 1 )
print ( '1D array image to 2D:' , samp_arr_img ( array_img_1d_to_2d ) . getInfo ())
# [[0],
# [1],
# [2],
# [3],
# [4],
# [5]]
# Calculate min and max for 2D array, use the fieldAxis parameter.
min_max_1d = array_img_1d_to_2d . arrayReduce ( ee . Reducer . minMax (), [ 0 ], 1 )
print ( '1D array image minMax (pixel):' , samp_arr_img ( min_max_1d ) . getInfo ())
# [[0, 5]]
# If your array image is 2D and you want min and max, add a third dimension.
array_img_2d_to_3d = array_img_2d . toArray ( 2 )
print ( '2D array image to 3D:' , samp_arr_img ( array_img_2d_to_3d ) . getInfo ())
# [[[0], [1], [2]],
# [[3], [4], [5]]]
# Calculate min and max along the 0-axis, store results in 2-axis.
min_max_2d = array_img_2d_to_3d . arrayReduce ( ee . Reducer . minMax (), [ 0 ], 2 )
print ( '2D array image minMax (pixel):' , samp_arr_img ( min_max_2d ) . getInfo ())
# [[[0, 3],
# [1, 4],
# [2, 5]]]
의견 보내기
달리 명시되지 않는 한 이 페이지의 콘텐츠에는 Creative Commons Attribution 4.0 라이선스 에 따라 라이선스가 부여되며, 코드 샘플에는 Apache 2.0 라이선스 에 따라 라이선스가 부여됩니다. 자세한 내용은 Google Developers 사이트 정책 을 참조하세요. 자바는 Oracle 및/또는 Oracle 계열사의 등록 상표입니다.
최종 업데이트: 2025-07-26(UTC)
의견을 전달하고 싶나요?
[[["이해하기 쉬움","easyToUnderstand","thumb-up"],["문제가 해결됨","solvedMyProblem","thumb-up"],["기타","otherUp","thumb-up"]],[["필요한 정보가 없음","missingTheInformationINeed","thumb-down"],["너무 복잡함/단계 수가 너무 많음","tooComplicatedTooManySteps","thumb-down"],["오래됨","outOfDate","thumb-down"],["번역 문제","translationIssue","thumb-down"],["샘플/코드 문제","samplesCodeIssue","thumb-down"],["기타","otherDown","thumb-down"]],["최종 업데이트: 2025-07-26(UTC)"],[[["`Image.arrayReduce()` reduces elements of each array pixel along the specified axes using a provided reducer."],["It takes an input image, a reducer function, a list of axes to reduce, and an optional field axis for reducers with multiple inputs or outputs."],["The output image has a length of 1 in all reduced axes."],["For reducers with multiple outputs, you may need to add dimensions to the input array to store the results."],["Examples show reducing 1D and 2D array images using `ee.Reducer.sum()` and `ee.Reducer.minMax()`."]]],["The `arrayReduce` method reduces elements within each array pixel of an image. It takes a `reducer`, a list of `axes` to reduce, and optionally, a `fieldAxis` for reducers with multiple inputs or outputs. The method collapses the specified axes to a length of 1. Example operations include summing elements in 1D or 2D arrays along specified axes or calculating the min/max with multiple outputs, requiring adjusted dimensions. The results are displayed as array pixels.\n"]]