Announcement: All noncommercial projects registered to use Earth Engine beforeApril 15, 2025 mustverify noncommercial eligibility to maintain access. If you have not verified by September 26, 2025, your access may be on hold.

ee.Image.arrayDotProduct

  • ThearrayDotProduct function computes the dot product of corresponding 1-D array bands from two input images.

  • This function is called on the first image (image1) and takes the second image (image2) as an argument.

  • Both input images,image1 andimage2, must be images containing 1-D array vectors.

  • The function returns anImage where each pixel's value is the dot product of the corresponding pixel's 1-D arrays from the input images.

Computes the dot product of each pair of 1-D arrays in the bands of the input images.

UsageReturns
Image.arrayDotProduct(image2)Image
ArgumentTypeDetails
this:image1ImageFirst array image of 1-D vectors.
image2ImageSecond array image of 1-D vectors.

Examples

Code Editor (JavaScript)

// A function to print arrays for a selected pixel in the following examples.functionsampArrImg(arrImg){varpoint=ee.Geometry.Point([-121,42]);returnarrImg.sample(point,500).first().get('array');}// A 1D array image.vararrayImg1Da=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.vararrayImg1Db=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.vartest=arrayImg1Da.arrayDotProduct(arrayImg1Db);print('A⋅B = 0(3) + 1(4) + 2(5) = ',sampArrImg(test));// 14

Python setup

See the Python Environment page for information on the Python API and usinggeemap for interactive development.

importeeimportgeemap.coreasgeemap

Colab (Python)

# A function to print arrays for a selected pixel in the following examples.defsamp_arr_img(arr_img):point=ee.Geometry.Point([-121,42])returnarr_img.sample(point,500).first().get('array')# A 1D array image.array_img_1d_a=ee.Image([0,1,2]).toArray()display('1D array image A (pixel):',samp_arr_img(array_img_1d_a))# [0, 1, 2]# A second 1D array image of the same length.array_img_1d_b=ee.Image([3,4,5]).toArray()display('1D array image B (pixel):',samp_arr_img(array_img_1d_b))# [3, 4, 5]# Calculate the dot product for the two 1D arrays.test=array_img_1d_a.arrayDotProduct(array_img_1d_b)display('A⋅B = 0(3) + 1(4) + 2(5) = ',samp_arr_img(test))# 14

Except as otherwise noted, the content of this page is licensed under theCreative Commons Attribution 4.0 License, and code samples are licensed under theApache 2.0 License. For details, see theGoogle Developers Site Policies. Java is a registered trademark of Oracle and/or its affiliates.

Last updated 2023-10-06 UTC.