ee.Image.arrayDotProduct
จัดทุกอย่างให้เป็นระเบียบอยู่เสมอด้วยคอลเล็กชัน
บันทึกและจัดหมวดหมู่เนื้อหาตามค่ากำหนดของคุณ
คำนวณผลคูณแบบดอทของอาร์เรย์ 1 มิติแต่ละคู่ในแถบของรูปภาพอินพุต
การใช้งาน | การคืนสินค้า |
---|
Image.arrayDotProduct(image2) | รูปภาพ |
อาร์กิวเมนต์ | ประเภท | รายละเอียด |
---|
ดังนี้ image1 | รูปภาพ | อาร์เรย์รูปภาพแรกของเวกเตอร์ 1 มิติ |
image2 | รูปภาพ | อาร์เรย์ที่ 2 ของเวกเตอร์ 1 มิติ |
ตัวอย่าง
โปรแกรมแก้ไขโค้ด (JavaScript)
// 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');
}
// A 1D array image.
var arrayImg1Da = ee.Image([0, 1, 2]).toArray();
print('1D array image A (pixel)', sampArrImg(arrayImg1Da));
// [0, 1, 2]
// A second 1D array image of the same length.
var arrayImg1Db = ee.Image([3, 4, 5]).toArray();
print('1D array image B (pixel)', sampArrImg(arrayImg1Db));
// [3, 4, 5]
// Calculate the dot product for the two 1D arrays.
var test = arrayImg1Da.arrayDotProduct(arrayImg1Db);
print('A⋅B = 0(3) + 1(4) + 2(5) = ', sampArrImg(test));
// 14
การตั้งค่า Python
ดูข้อมูลเกี่ยวกับ Python API และการใช้ geemap
เพื่อการพัฒนาแบบอินเทอร์แอกทีฟได้ที่หน้า
สภาพแวดล้อม Python
import ee
import geemap.core as geemap
Colab (Python)
# 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')
# A 1D array image.
array_img_1d_a = ee.Image([0, 1, 2]).toArray()
print('1D array image A (pixel):', samp_arr_img(array_img_1d_a).getInfo())
# [0, 1, 2]
# A second 1D array image of the same length.
array_img_1d_b = ee.Image([3, 4, 5]).toArray()
print('1D array image B (pixel):', samp_arr_img(array_img_1d_b).getInfo())
# [3, 4, 5]
# Calculate the dot product for the two 1D arrays.
test = array_img_1d_a.arrayDotProduct(array_img_1d_b)
print('A⋅B = 0(3) + 1(4) + 2(5) = ', samp_arr_img(test).getInfo())
# 14
เนื้อหาของหน้าเว็บนี้ได้รับอนุญาตภายใต้ใบอนุญาตที่ต้องระบุที่มาของครีเอทีฟคอมมอนส์ 4.0 และตัวอย่างโค้ดได้รับอนุญาตภายใต้ใบอนุญาต Apache 2.0 เว้นแต่จะระบุไว้เป็นอย่างอื่น โปรดดูรายละเอียดที่นโยบายเว็บไซต์ Google Developers Java เป็นเครื่องหมายการค้าจดทะเบียนของ Oracle และ/หรือบริษัทในเครือ
อัปเดตล่าสุด 2025-07-26 UTC
[null,null,["อัปเดตล่าสุด 2025-07-26 UTC"],[[["\u003cp\u003eComputes the dot product of corresponding 1-D arrays within two input images, resulting in a new image.\u003c/p\u003e\n"],["\u003cp\u003eEach 1-D array represents a band in the input images, and they must have the same length.\u003c/p\u003e\n"],["\u003cp\u003eThe dot product calculation is performed element-wise between the arrays in matching bands.\u003c/p\u003e\n"],["\u003cp\u003eThe resulting image contains a single band representing the dot product values for each pixel location.\u003c/p\u003e\n"]]],["The `arrayDotProduct` function computes the dot product between two 1-D array images. It takes two image arguments, `image1` and `image2`, representing the first and second array images respectively. The dot product is calculated for each corresponding pair of 1-D arrays in the images' bands. The result is an `Image` representing the dot product. The example illustrates this using arrays [0, 1, 2] and [3, 4, 5], yielding a dot product of 14.\n"],null,["# ee.Image.arrayDotProduct\n\nComputes the dot product of each pair of 1-D arrays in the bands of the input images.\n\n\u003cbr /\u003e\n\n| Usage | Returns |\n|---------------------------------|---------|\n| Image.arrayDotProduct`(image2)` | Image |\n\n| Argument | Type | Details |\n|----------------|-------|------------------------------------|\n| this: `image1` | Image | First array image of 1-D vectors. |\n| `image2` | Image | Second array image of 1-D vectors. |\n\nExamples\n--------\n\n### Code Editor (JavaScript)\n\n```javascript\n// A function to print arrays 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// A 1D array image.\nvar arrayImg1Da = ee.Image([0, 1, 2]).toArray();\nprint('1D array image A (pixel)', sampArrImg(arrayImg1Da));\n// [0, 1, 2]\n\n// A second 1D array image of the same length.\nvar arrayImg1Db = ee.Image([3, 4, 5]).toArray();\nprint('1D array image B (pixel)', sampArrImg(arrayImg1Db));\n// [3, 4, 5]\n\n// Calculate the dot product for the two 1D arrays.\nvar test = arrayImg1Da.arrayDotProduct(arrayImg1Db);\nprint('A⋅B = 0(3) + 1(4) + 2(5) = ', sampArrImg(test));\n// 14\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 arrays 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# A 1D array image.\narray_img_1d_a = ee.Image([0, 1, 2]).toArray()\nprint('1D array image A (pixel):', samp_arr_img(array_img_1d_a).getInfo())\n# [0, 1, 2]\n\n# A second 1D array image of the same length.\narray_img_1d_b = ee.Image([3, 4, 5]).toArray()\nprint('1D array image B (pixel):', samp_arr_img(array_img_1d_b).getInfo())\n# [3, 4, 5]\n\n# Calculate the dot product for the two 1D arrays.\ntest = array_img_1d_a.arrayDotProduct(array_img_1d_b)\nprint('A⋅B = 0(3) + 1(4) + 2(5) = ', samp_arr_img(test).getInfo())\n# 14\n```"]]