공지사항:
2025년 4월 15일 전에 Earth Engine 사용을 위해 등록된 모든 비상업용 프로젝트는 Earth Engine 액세스를 유지하기 위해
비상업용 자격 요건을 인증해야 합니다.
ee.Image.arrayPad
컬렉션을 사용해 정리하기
내 환경설정을 기준으로 콘텐츠를 저장하고 분류하세요.
각 픽셀의 배열 값을 고정 길이로 채웁니다. 패딩 값은 각 배열에 추가되어 각 축을 따라 지정된 길이로 확장됩니다. 이미지의 모든 밴드는 배열 값이어야 하며 크기가 동일해야 합니다.
사용 | 반환 값 |
---|
Image.arrayPad(lengths, pad) | 이미지 |
인수 | 유형 | 세부정보 |
---|
this: image | 이미지 | 패딩할 이미지 배열 |
lengths | 목록 | 출력 배열의 각 축에 원하는 길이의 목록입니다. 배열이 이미 주어진 길이보다 크거나 같은 경우 해당 축을 따라 변경되지 않습니다. |
pad | 숫자, 기본값: 0 | 패딩할 값입니다. |
예
코드 편집기 (JavaScript)
// A function to print the array 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.
var arrayImg1D = ee.Image([0, 1, 2]).toArray();
print('1D array image (pixel)', sampArrImg(arrayImg1D));
// [0, 1, 2]
// Pad 1D array to length of 5 with value 9.
var arrayImg1Dpad = arrayImg1D.arrayPad([5], 9);
print('1D array image padded', sampArrImg(arrayImg1Dpad));
// [0, 1, 2, 9, 9]
// Create a 2D array image.
var arrayImg2D = ee.Image([0, 1, 2, 3, 4, 5]).toArray()
.arrayReshape(ee.Image([2, 3]).toArray(), 2);
print('2D 2x3 array image (pixel)', sampArrImg(arrayImg2D));
// [[0, 1, 2],
// [3, 4, 5]]
// Pad 2D array to 0-axis length 3 and 1-axis length 5 with value 9.
var arrayImg2Dpad = arrayImg2D.arrayPad([3, 5], 9);
print('2D array image padded', sampArrImg(arrayImg2Dpad));
// [[0, 1, 2, 9, 9],
// [3, 4, 5, 9, 9],
// [9, 9, 9, 9, 9]]
Python 설정
Python API 및 대화형 개발을 위한 geemap
사용에 관한 자세한 내용은
Python 환경 페이지를 참고하세요.
import ee
import geemap.core as geemap
Colab (Python)
# A function to print the array 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.
array_img_1d = ee.Image([0, 1, 2]).toArray()
print('1D array image (pixel):', samp_arr_img(array_img_1d).getInfo())
# [0, 1, 2]
# Pad 1D array to length of 5 with value 9.
array_img_1d_pad = array_img_1d.arrayPad([5], 9)
print('1D array image padded:', samp_arr_img(array_img_1d_pad).getInfo())
# [0, 1, 2, 9, 9]
# Create a 2D array image.
array_img_2d = ee.Image([0, 1, 2, 3, 4, 5]).toArray().arrayReshape(
ee.Image([2, 3]).toArray(),
2
)
print('2D 2x3 array image (pixel):', samp_arr_img(array_img_2d).getInfo())
# [[0, 1, 2],
# [3, 4, 5]]
# Pad 2D array to 0-axis length 3 and 1-axis length 5 with value 9.
array_img_2d_pad = array_img_2d.arrayPad([3, 5], 9)
print('2D array image padded:', samp_arr_img(array_img_2d_pad).getInfo())
# [[0, 1, 2, 9, 9],
# [3, 4, 5, 9, 9],
# [9, 9, 9, 9, 9]]
달리 명시되지 않는 한 이 페이지의 콘텐츠에는 Creative Commons Attribution 4.0 라이선스에 따라 라이선스가 부여되며, 코드 샘플에는 Apache 2.0 라이선스에 따라 라이선스가 부여됩니다. 자세한 내용은 Google Developers 사이트 정책을 참조하세요. 자바는 Oracle 및/또는 Oracle 계열사의 등록 상표입니다.
최종 업데이트: 2025-07-25(UTC)
[null,null,["최종 업데이트: 2025-07-25(UTC)"],[[["\u003cp\u003e\u003ccode\u003earrayPad\u003c/code\u003e extends the array values in each image pixel to a specified length using a provided pad value.\u003c/p\u003e\n"],["\u003cp\u003eIt accepts an array image, a list of desired lengths for each axis, and an optional pad value (defaulting to 0).\u003c/p\u003e\n"],["\u003cp\u003eIf an array is already at or beyond the desired length, it remains unchanged along that axis.\u003c/p\u003e\n"],["\u003cp\u003eAll bands in the image must be array-valued and share the same dimensions for the function to work correctly.\u003c/p\u003e\n"],["\u003cp\u003eThis function is useful for standardizing array lengths in images for further processing.\u003c/p\u003e\n"]]],[],null,["# ee.Image.arrayPad\n\nPads the array values in each pixel to be a fixed length. The pad value will be appended to each array to extend it to given length along each axis. All bands of the image must be array-valued and have the same dimensions.\n\n\u003cbr /\u003e\n\n| Usage | Returns |\n|------------------------------------|---------|\n| Image.arrayPad`(lengths, `*pad*`)` | Image |\n\n| Argument | Type | Details |\n|---------------|--------------------|--------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| this: `image` | Image | Array image to pad. |\n| `lengths` | List | A list of desired lengths for each axis in the output arrays. Arrays are already as large or larger than the given length will be unchanged along that axis. |\n| `pad` | Number, default: 0 | The value to pad with. |\n\nExamples\n--------\n\n### Code Editor (JavaScript)\n\n```javascript\n// A function to print the array for a selected pixel in the following examples.\nfunction sampArrImg(arrImg) {\n var point = ee.Geometry.Point([-121, 42]);\n return arrImg.sample(point, 500).first().get('array');\n}\n\n// Create a 1D array image.\nvar arrayImg1D = ee.Image([0, 1, 2]).toArray();\nprint('1D array image (pixel)', sampArrImg(arrayImg1D));\n// [0, 1, 2]\n\n// Pad 1D array to length of 5 with value 9.\nvar arrayImg1Dpad = arrayImg1D.arrayPad([5], 9);\nprint('1D array image padded', sampArrImg(arrayImg1Dpad));\n// [0, 1, 2, 9, 9]\n\n// Create a 2D array image.\nvar arrayImg2D = ee.Image([0, 1, 2, 3, 4, 5]).toArray()\n .arrayReshape(ee.Image([2, 3]).toArray(), 2);\nprint('2D 2x3 array image (pixel)', sampArrImg(arrayImg2D));\n// [[0, 1, 2],\n// [3, 4, 5]]\n\n// Pad 2D array to 0-axis length 3 and 1-axis length 5 with value 9.\nvar arrayImg2Dpad = arrayImg2D.arrayPad([3, 5], 9);\nprint('2D array image padded', sampArrImg(arrayImg2Dpad));\n// [[0, 1, 2, 9, 9],\n// [3, 4, 5, 9, 9],\n// [9, 9, 9, 9, 9]]\n```\nPython setup\n\nSee the [Python Environment](/earth-engine/guides/python_install) page for information on the Python API and using\n`geemap` for interactive development. \n\n```python\nimport ee\nimport geemap.core as geemap\n```\n\n### Colab (Python)\n\n```python\n# A function to print the array for a selected pixel in the following examples.\ndef samp_arr_img(arr_img):\n point = ee.Geometry.Point([-121, 42])\n return arr_img.sample(point, 500).first().get('array')\n\n# Create a 1D array image.\narray_img_1d = ee.Image([0, 1, 2]).toArray()\nprint('1D array image (pixel):', samp_arr_img(array_img_1d).getInfo())\n# [0, 1, 2]\n\n# Pad 1D array to length of 5 with value 9.\narray_img_1d_pad = array_img_1d.arrayPad([5], 9)\nprint('1D array image padded:', samp_arr_img(array_img_1d_pad).getInfo())\n# [0, 1, 2, 9, 9]\n\n# Create a 2D array image.\narray_img_2d = ee.Image([0, 1, 2, 3, 4, 5]).toArray().arrayReshape(\n ee.Image([2, 3]).toArray(),\n 2\n)\nprint('2D 2x3 array image (pixel):', samp_arr_img(array_img_2d).getInfo())\n# [[0, 1, 2],\n# [3, 4, 5]]\n\n# Pad 2D array to 0-axis length 3 and 1-axis length 5 with value 9.\narray_img_2d_pad = array_img_2d.arrayPad([3, 5], 9)\nprint('2D array image padded:', samp_arr_img(array_img_2d_pad).getInfo())\n# [[0, 1, 2, 9, 9],\n# [3, 4, 5, 9, 9],\n# [9, 9, 9, 9, 9]]\n```"]]