Объявление : Все некоммерческие проекты, зарегистрированные для использования Earth Engine до
15 апреля 2025 года, должны
подтвердить некоммерческое право на сохранение доступа к Earth Engine.
ee.Image.arrayRepeat
Оптимизируйте свои подборки
Сохраняйте и классифицируйте контент в соответствии со своими настройками.
Повторяет каждый пиксель массива вдоль заданной оси. Каждый выходной пиксель будет иметь форму входного пикселя, за исключением длины вдоль повторяющейся оси, которая будет умножена на количество копий.
Использование | Возврат | Image. arrayRepeat (axis, copies) | Изображение |
Аргумент | Тип | Подробности | это: input | Изображение | Изображение пикселей массива, которое необходимо повторить. |
axis | Целое число | Ось, вдоль которой будет повторяться массив каждого пикселя. |
copies | Изображение | Количество копий каждого пикселя. |
Примеры
Редактор кода (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]
// Repeat a 1D array along the 0-axis 3 times.
var repeat1DAx0 = arrayImg1D.arrayRepeat(0, 3);
print('1D array repeated 3 times on 0-axis', sampArrImg(repeat1DAx0));
// [0, 1, 2, 0, 1, 2, 0, 1, 2]
// Repeat a 1D array along the 1-axis 3 times (expands the dimensions).
var repeat1DAx1 = arrayImg1D.arrayRepeat(1, 3);
print('1D array repeated 3 times on 1-axis', sampArrImg(repeat1DAx1));
// [[0, 0, 0],
// [1, 1, 1],
// [2, 2, 2]]
// Repeat a 2D array along the 0-axis 2 times.
var repeat2DAx0 = repeat1DAx1.arrayRepeat(0, 2);
print('2D array repeated 2 times on 0-axis', sampArrImg(repeat2DAx0));
// [[0, 0, 0],
// [1, 1, 1],
// [2, 2, 2],
// [0, 0, 0],
// [1, 1, 1],
// [2, 2, 2]]
// Repeat a 2D array along the 1-axis 2 times.
var repeat2DAx1 = repeat1DAx1.arrayRepeat(1, 2);
print('2D array repeated 2 times on 1-axis', sampArrImg(repeat2DAx1));
// [[0, 0, 0, 0, 0, 0],
// [1, 1, 1, 1, 1, 1],
// [2, 2, 2, 2, 2, 2]]
Настройка Python
Информацию об API Python и использовании 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]
# Repeat a 1D array along the 0-axis 3 times.
repeat_1d_ax0 = array_img_1d.arrayRepeat(0, 3)
print(
'1D array repeated 3 times on 0-axis:',
samp_arr_img(repeat_1d_ax0).getInfo()
)
# [0, 1, 2, 0, 1, 2, 0, 1, 2]
# Repeat a 1D array along the 1-axis 3 times (expands the dimensions).
repeat_1d_ax1 = array_img_1d.arrayRepeat(1, 3)
print(
'1D array repeated 3 times on 1-axis:',
samp_arr_img(repeat_1d_ax1).getInfo()
)
# [[0, 0, 0],
# [1, 1, 1],
# [2, 2, 2]]
# Repeat a 2D array along the 0-axis 2 times.
repeat_2d_ax0 = repeat_1d_ax1.arrayRepeat(0, 2)
print(
'2D array repeated 2 times on 0-axis:',
samp_arr_img(repeat_2d_ax0).getInfo()
)
# [[0, 0, 0],
# [1, 1, 1],
# [2, 2, 2],
# [0, 0, 0],
# [1, 1, 1],
# [2, 2, 2]]
# Repeat a 2D array along the 1-axis 2 times.
repeat_2d_ax1 = repeat_1d_ax1.arrayRepeat(1, 2)
print(
'2D array repeated 2 times on 1-axis:',
samp_arr_img(repeat_2d_ax1).getInfo()
)
# [[0, 0, 0, 0, 0, 0],
# [1, 1, 1, 1, 1, 1],
# [2, 2, 2, 2, 2, 2]]
Если не указано иное, контент на этой странице предоставляется по лицензии Creative Commons "С указанием авторства 4.0", а примеры кода – по лицензии Apache 2.0. Подробнее об этом написано в правилах сайта. Java – это зарегистрированный товарный знак корпорации Oracle и ее аффилированных лиц.
Последнее обновление: 2025-07-24 UTC.
[null,null,["Последнее обновление: 2025-07-24 UTC."],[[["\u003cp\u003e\u003ccode\u003eImage.arrayRepeat()\u003c/code\u003e duplicates each pixel's array along a specified axis, creating a new image.\u003c/p\u003e\n"],["\u003cp\u003eThe \u003ccode\u003eaxis\u003c/code\u003e parameter determines the dimension along which the repetition occurs (0 or 1 for 1D/2D arrays).\u003c/p\u003e\n"],["\u003cp\u003eThe \u003ccode\u003ecopies\u003c/code\u003e parameter specifies the number of times to repeat the array elements along the given axis.\u003c/p\u003e\n"],["\u003cp\u003eRepeating along an existing axis extends the array in that dimension, while repeating along a new axis adds a new dimension to the array.\u003c/p\u003e\n"],["\u003cp\u003eThis function is useful for expanding array images or creating patterned data within an image's array structure.\u003c/p\u003e\n"]]],[],null,["# ee.Image.arrayRepeat\n\nRepeats each array pixel along the given axis. Each output pixel will have the shape of the input pixel, except length along the repeated axis, which will be multiplied by the number of copies.\n\n\u003cbr /\u003e\n\n| Usage | Returns |\n|-----------------------------------|---------|\n| Image.arrayRepeat`(axis, copies)` | Image |\n\n| Argument | Type | Details |\n|---------------|---------|------------------------------------------------|\n| this: `input` | Image | Image of array pixels to be repeated. |\n| `axis` | Integer | Axis along which to repeat each pixel's array. |\n| `copies` | Image | Number of copies of each pixel. |\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// Repeat a 1D array along the 0-axis 3 times.\nvar repeat1DAx0 = arrayImg1D.arrayRepeat(0, 3);\nprint('1D array repeated 3 times on 0-axis', sampArrImg(repeat1DAx0));\n// [0, 1, 2, 0, 1, 2, 0, 1, 2]\n\n// Repeat a 1D array along the 1-axis 3 times (expands the dimensions).\nvar repeat1DAx1 = arrayImg1D.arrayRepeat(1, 3);\nprint('1D array repeated 3 times on 1-axis', sampArrImg(repeat1DAx1));\n// [[0, 0, 0],\n// [1, 1, 1],\n// [2, 2, 2]]\n\n// Repeat a 2D array along the 0-axis 2 times.\nvar repeat2DAx0 = repeat1DAx1.arrayRepeat(0, 2);\nprint('2D array repeated 2 times on 0-axis', sampArrImg(repeat2DAx0));\n// [[0, 0, 0],\n// [1, 1, 1],\n// [2, 2, 2],\n// [0, 0, 0],\n// [1, 1, 1],\n// [2, 2, 2]]\n\n// Repeat a 2D array along the 1-axis 2 times.\nvar repeat2DAx1 = repeat1DAx1.arrayRepeat(1, 2);\nprint('2D array repeated 2 times on 1-axis', sampArrImg(repeat2DAx1));\n// [[0, 0, 0, 0, 0, 0],\n// [1, 1, 1, 1, 1, 1],\n// [2, 2, 2, 2, 2, 2]]\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# Repeat a 1D array along the 0-axis 3 times.\nrepeat_1d_ax0 = array_img_1d.arrayRepeat(0, 3)\nprint(\n '1D array repeated 3 times on 0-axis:',\n samp_arr_img(repeat_1d_ax0).getInfo()\n)\n# [0, 1, 2, 0, 1, 2, 0, 1, 2]\n\n# Repeat a 1D array along the 1-axis 3 times (expands the dimensions).\nrepeat_1d_ax1 = array_img_1d.arrayRepeat(1, 3)\nprint(\n '1D array repeated 3 times on 1-axis:',\n samp_arr_img(repeat_1d_ax1).getInfo()\n)\n# [[0, 0, 0],\n# [1, 1, 1],\n# [2, 2, 2]]\n\n# Repeat a 2D array along the 0-axis 2 times.\nrepeat_2d_ax0 = repeat_1d_ax1.arrayRepeat(0, 2)\nprint(\n '2D array repeated 2 times on 0-axis:',\n samp_arr_img(repeat_2d_ax0).getInfo()\n)\n# [[0, 0, 0],\n# [1, 1, 1],\n# [2, 2, 2],\n# [0, 0, 0],\n# [1, 1, 1],\n# [2, 2, 2]]\n\n# Repeat a 2D array along the 1-axis 2 times.\nrepeat_2d_ax1 = repeat_1d_ax1.arrayRepeat(1, 2)\nprint(\n '2D array repeated 2 times on 1-axis:',\n samp_arr_img(repeat_2d_ax1).getInfo()\n)\n# [[0, 0, 0, 0, 0, 0],\n# [1, 1, 1, 1, 1, 1],\n# [2, 2, 2, 2, 2, 2]]\n```"]]