ee.Array.pow

On an element-wise basis, raises the first value to the power of the second.

UsageReturns
Array.pow(right)Array
ArgumentTypeDetails
this: leftArrayThe left-hand value.
rightArrayThe right-hand value.

Examples

Code Editor (JavaScript)

var empty = ee.Array([], ee.PixelType.int8());
print(empty.pow(empty));  // []

// [0.25,-0.5,1,-2,4,-8]
print(ee.Array([-2, -2, -2, -2, -2, -2]).pow([-2, -1, 0, 1, 2, 3]));

// [1,-1,1,-1,1,-1]
print(ee.Array([-1, -1, -1, -1, -1, -1]).pow([-2, -1, 0, 1, 2, 3]));

// print(ee.Array([0, 0, 0, 0, 0, 0]).pow([-2, -1, 0, 1, 2, 3]));
print(ee.Array([0, 0, 0, 0]).pow([0, 1, 2, 3]));

// [1,1,1,1,1,1]
print(ee.Array([1, 1, 1, 1, 1, 1]).pow([-2, -1, 0, 1, 2, 3]));

// [0.25,0.5,1,2,4,8]
print(ee.Array([2, 2, 2, 2, 2, 2]).pow([-2, -1, 0, 1, 2, 3]));

// [0.009999999776482582,
//  0.10000000149011612,
//  1,
//  10,
//  100,
//  1000]
print(ee.Array([10, 10, 10, 10, 10, 10]).pow([-2, -1, 0, 1, 2, 3]));

// [0.009999999776482582,
//  0.10000000149011612,
//  1,
//  10,
//  100,
//  1000]
print(ee.Array([10, 10, 10, 10, 10, 10], ee.PixelType.int32())
        .pow([-2, -1, 0, 1, 2, 3]));

Python setup

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

import ee
import geemap.core as geemap

Colab (Python)

empty = ee.Array([], ee.PixelType.int8())
display(empty.pow(empty))  # []

# [0.25, -0.5, 1, -2, 4, -8]
display(ee.Array([-2, -2, -2, -2, -2, -2]).pow([-2, -1, 0, 1, 2, 3]))

# [1, -1, 1, -1, 1, -1]
display(ee.Array([-1, -1, -1, -1, -1, -1]).pow([-2, -1, 0, 1, 2, 3]))

# ['Infinity', 'Infinity', 1, 0, 0, 0]
display(ee.Array([0, 0, 0, 0, 0, 0]).pow([-2, -1, 0, 1, 2, 3]))

# [1, 0, 0, 0]
display(ee.Array([0, 0, 0, 0]).pow([0, 1, 2, 3]))

# [1, 1, 1, 1, 1, 1]
display(ee.Array([1, 1, 1, 1, 1, 1]).pow([-2, -1, 0, 1, 2, 3]))

# [0.25, 0.5, 1, 2, 4, 8]
display(ee.Array([2, 2, 2, 2, 2, 2]).pow([-2, -1, 0, 1, 2, 3]))

# [0.009999999776482582,
#  0.10000000149011612,
#  1,
#  10,
#  100,
#  1000]
display(ee.Array([10, 10, 10, 10, 10, 10]).pow([-2, -1, 0, 1, 2, 3]))

# [0.009999999776482582,
#  0.10000000149011612,
#  1,
#  10,
#  100,
#  1000]
display(ee.Array([10, 10, 10, 10, 10, 10], ee.PixelType.int32())
        .pow([-2, -1, 0, 1, 2, 3]))