ee.Image.arrayRepeat

هر پیکسل آرایه را در امتداد محور داده شده تکرار می کند. هر پیکسل خروجی شکل پیکسل ورودی را خواهد داشت، به جز طول در امتداد محور مکرر که در تعداد کپی ها ضرب می شود.

استفاده برمی گرداند
Image. arrayRepeat (axis, copies) تصویر
استدلال تایپ کنید جزئیات
این: input تصویر تصویر پیکسل های آرایه که باید تکرار شوند.
axis عدد صحیح محوری که در امتداد آن آرایه هر پیکسل تکرار شود.
copies تصویر تعداد کپی از هر پیکسل

نمونه ها

ویرایشگر کد (جاوا اسکریپت)

// 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]]

راه اندازی پایتون

برای اطلاعات در مورد API پایتون و استفاده از geemap برای توسعه تعاملی به صفحه محیط پایتون مراجعه کنید.

import ee
import geemap.core as geemap

کولب (پایتون)

# 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]]