ee.Image.arrayGet
संग्रह की मदद से व्यवस्थित रहें
अपनी प्राथमिकताओं के आधार पर, कॉन्टेंट को सेव करें और कैटगरी में बांटें.
हर बैंड के लिए, उसी नाम का एक आउटपुट बैंड बनाया जाता है. इसमें दी गई पोज़िशन पर मौजूद वैल्यू को, उस बैंड में मौजूद इनपुट मल्टीडाइमेंशनल पिक्सल से निकाला जाता है.
इस्तेमाल | रिटर्न |
---|
Image.arrayGet(position) | इमेज |
आर्ग्यूमेंट | टाइप | विवरण |
---|
यह: image | इमेज | वह कलेक्शन जिससे कोई एलिमेंट लेना है. |
position | इमेज | जिस एलिमेंट के निर्देशांक पाने हैं. इनपुट इमेज में जितने डाइमेंशन हैं उतने ही स्केलर बैंड होने चाहिए. |
उदाहरण
कोड एडिटर (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, 3, 4, 5]).toArray();
print('1D array image (pixel)', sampArrImg(arrayImg1D));
// [0, 1, 2, 3, 4, 5]
// Get the array value at a given position. Here we target the 4th element.
var position1D = ee.Image([3]);
var selectedElement1D = arrayImg1D.arrayGet(position1D);
print('Element at position [3] (4th element)', sampArrImg(selectedElement1D));
// [3]
// Create a 2D 2x3 array image (reshape the 1D array image).
var arrayImg2D = arrayImg1D.arrayReshape(ee.Image([2, 3]).toArray(), 2);
print('2D 2x3 array image (pixel)', sampArrImg(arrayImg2D));
// [[0, 1, 2],
// [3, 4, 5]]
// Get the array element value at axis-0, position 0 and axis-1, position 2.
var position2D = ee.Image([0, 2]);
var selectedElement2D = arrayImg2D.arrayGet(position2D);
print('Element at position [0, 2]', sampArrImg(selectedElement2D));
// 2
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, 3, 4, 5]).toArray()
print('1D array image (pixel):', samp_arr_img(array_img_1d).getInfo())
# [0, 1, 2, 3, 4, 5]
# Get the array value at a given position. Here we target the 4th element.
position_1d = ee.Image([3])
selected_element_1d = array_img_1d.arrayGet(position_1d)
print(
'Element at position [3] (4th element):',
samp_arr_img(selected_element_1d).getInfo()
)
# [3]
# Create a 2D 2x3 array image (reshape the 1D array image).
array_img_2d = array_img_1d.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]]
# Get the array element value at axis-0, position 0 and axis-1, position 2.
position_2d = ee.Image([0, 2])
selected_element_2d = array_img_2d.arrayGet(position_2d)
print(
'Element at position [0, 2]:',
samp_arr_img(selected_element_2d).getInfo()
)
# 2
जब तक कुछ अलग से न बताया जाए, तब तक इस पेज की सामग्री को Creative Commons Attribution 4.0 License के तहत और कोड के नमूनों को Apache 2.0 License के तहत लाइसेंस मिला है. ज़्यादा जानकारी के लिए, Google Developers साइट नीतियां देखें. Oracle और/या इससे जुड़ी हुई कंपनियों का, Java एक रजिस्टर किया हुआ ट्रेडमार्क है.
आखिरी बार 2025-07-26 (UTC) को अपडेट किया गया.
[null,null,["आखिरी बार 2025-07-26 (UTC) को अपडेट किया गया."],[[["\u003cp\u003e\u003ccode\u003earrayGet\u003c/code\u003e extracts a single value from a specific position within a multidimensional array image, creating a new image band containing that value.\u003c/p\u003e\n"],["\u003cp\u003eThe position within the array is specified using an Image where each band represents the index along a different dimension of the array.\u003c/p\u003e\n"],["\u003cp\u003eThe output image has the same name as the input band and contains the extracted value at the specified position for each pixel.\u003c/p\u003e\n"],["\u003cp\u003eThis function is useful for accessing individual elements or slices of data within a larger array structure.\u003c/p\u003e\n"]]],[],null,["# ee.Image.arrayGet\n\nFor each band, an output band of the same name is created with the value at the given position extracted from the input multidimensional pixel in that band.\n\n\u003cbr /\u003e\n\n| Usage | Returns |\n|----------------------------|---------|\n| Image.arrayGet`(position)` | Image |\n\n| Argument | Type | Details |\n|---------------|-------|-----------------------------------------------------------------------------------------------------------------------|\n| this: `image` | Image | Array to get an element from. |\n| `position` | Image | The coordinates of the element to get. There must be as many scalar bands as there are dimensions in the input image. |\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, 3, 4, 5]).toArray();\nprint('1D array image (pixel)', sampArrImg(arrayImg1D));\n// [0, 1, 2, 3, 4, 5]\n\n// Get the array value at a given position. Here we target the 4th element.\nvar position1D = ee.Image([3]);\nvar selectedElement1D = arrayImg1D.arrayGet(position1D);\nprint('Element at position [3] (4th element)', sampArrImg(selectedElement1D));\n// [3]\n\n// Create a 2D 2x3 array image (reshape the 1D array image).\nvar arrayImg2D = arrayImg1D.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// Get the array element value at axis-0, position 0 and axis-1, position 2.\nvar position2D = ee.Image([0, 2]);\nvar selectedElement2D = arrayImg2D.arrayGet(position2D);\nprint('Element at position [0, 2]', sampArrImg(selectedElement2D));\n// 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, 3, 4, 5]).toArray()\nprint('1D array image (pixel):', samp_arr_img(array_img_1d).getInfo())\n# [0, 1, 2, 3, 4, 5]\n\n# Get the array value at a given position. Here we target the 4th element.\nposition_1d = ee.Image([3])\nselected_element_1d = array_img_1d.arrayGet(position_1d)\nprint(\n 'Element at position [3] (4th element):',\n samp_arr_img(selected_element_1d).getInfo()\n)\n# [3]\n\n# Create a 2D 2x3 array image (reshape the 1D array image).\narray_img_2d = array_img_1d.arrayReshape(ee.Image([2, 3]).toArray(), 2)\nprint('2D 2x3 array image (pixel):', samp_arr_img(array_img_2d).getInfo())\n# [[0, 1, 2],\n# [3, 4, 5]]\n\n# Get the array element value at axis-0, position 0 and axis-1, position 2.\nposition_2d = ee.Image([0, 2])\nselected_element_2d = array_img_2d.arrayGet(position_2d)\nprint(\n 'Element at position [0, 2]:',\n samp_arr_img(selected_element_2d).getInfo()\n)\n# 2\n```"]]