ee.Image.arrayReshape

সমান আকৃতির, সম্ভবত বহুমাত্রিক পিক্সেল সহ একটি চিত্রের অ্যারে ব্যান্ডকে একটি নতুন আকৃতির অ্যারের ছবিতে রূপান্তর করে৷

ব্যবহার রিটার্নস
Image. arrayReshape (lengths, dimensions) ছবি
যুক্তি টাইপ বিস্তারিত
এই: image ছবি পুনঃআকৃতির জন্য অ্যারের চিত্র।
lengths ছবি একটি 1-ব্যান্ড চিত্র ইনপুট চিত্রের প্রতিটি অক্ষের নতুন দৈর্ঘ্য নির্দিষ্ট করে প্রতি পিক্সেল প্রতি 1-D অ্যারে হিসাবে নির্দিষ্ট করে৷ প্রতিটি আকৃতির অ্যারেতে 'মাত্রা' দৈর্ঘ্যের মান থাকা উচিত। যদি একটি দৈর্ঘ্য -1 হয়, তাহলে সেই অক্ষের জন্য সংশ্লিষ্ট দৈর্ঘ্য এমনভাবে গণনা করা হবে যাতে মোট আকার স্থির থাকে। বিশেষ করে, [-1] একটি আকৃতি 1-ডিতে সমতল হয়। আকৃতির সর্বাধিক একটি উপাদান -1 হতে পারে।
dimensions পূর্ণসংখ্যা সমস্ত আউটপুট অ্যারে পিক্সেল দ্বারা ভাগ করা মাত্রার সংখ্যা৷

উদাহরণ

কোড এডিটর (জাভাস্ক্রিপ্ট)

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

// Reshape the 1D 6-element array to a 2D 2 (row) x 3 (column) array. Notice
// that elements are filled row by row in the reshaped result.
var reshape2x3 = arrayImg1D.arrayReshape(ee.Image([2, 3]).toArray(), 2);
print('2D 2x3 array image (pixel)', sampArrImg(reshape2x3));
// [[0, 1, 2],
//  [3, 4, 5]]

// Use -1 to auto-determine a dimension length. For example, here we set
// 3 rows and let Earth Engine determine the number of columns needed.
var reshape3x_ = arrayImg1D.arrayReshape(ee.Image([3, -1]).toArray(), 2);
print('2D 3x? array image (pixel)', sampArrImg(reshape3x_));
// [[0, 1],
//  [2, 3],
//  [4, 5]]

// Flatten a 2D 2x3 array to 1D 6-element array.
var flattened = reshape2x3.arrayReshape(ee.Image([-1]).toArray(), 1);
print('2D array flattened to 1D', sampArrImg(flattened));
// [0, 1, 2, 3, 4, 5]

পাইথন সেটআপ

পাইথন এপিআই এবং ইন্টারেক্টিভ ডেভেলপমেন্টের জন্য geemap ব্যবহার করার জন্য পাইথন এনভায়রনমেন্ট পৃষ্ঠাটি দেখুন।

import ee
import geemap.core as geemap

Colab (পাইথন)

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

# Reshape the 1D 6-element array to a 2D 2 (row) x 3 (column) array. Notice
# that elements are filled row by row in the reshaped result.
reshape2x3 = array_img_1d.arrayReshape(ee.Image([2, 3]).toArray(), 2)
print('2D 2x3 array image (pixel):', samp_arr_img(reshape2x3).getInfo())
# [[0, 1, 2],
#  [3, 4, 5]]

# Use -1 to auto-determine a dimension length. For example, here we set
# 3 rows and let Earth Engine determine the number of columns needed.
reshape3x_ = array_img_1d.arrayReshape(ee.Image([3, -1]).toArray(), 2)
print('2D 3x? array image (pixel):', samp_arr_img(reshape3x_).getInfo())
# [[0, 1],
#  [2, 3],
#  [4, 5]]

# Flatten a 2D 2x3 array to 1D 6-element array.
flattened = reshape2x3.arrayReshape(ee.Image([-1]).toArray(), 1)
print('2D array flattened to 1D:', samp_arr_img(flattened).getInfo())
# [0, 1, 2, 3, 4, 5]