ee.Array.and
Stay organized with collections
Save and categorize content based on your preferences.
On an element-wise basis, returns 1 if and only if both values are non-zero.
Usage | Returns | Array.and(right) | Array |
Argument | Type | Details | this: left | Array | The left-hand value. |
right | Array | The right-hand value. |
Examples
Code Editor (JavaScript)
// Element-wise boolean "and" operator.
// Both arrays must be the same dimensions.
var arrayNeither = ee.Array([0, 0]);
var arrayFirst = ee.Array([1, 0]);
var arraySecond = ee.Array([0, 1]);
var arrayBoth = ee.Array([1, 1]);
// Any non-zero value is true.
var arrayLarger = ee.Array([-2, 2]);
print(arrayBoth.and(arrayLarger)); // [1, 1]
print(arrayBoth.and(arrayNeither)); // [0, 0]
print(arrayFirst.and(arraySecond)); // [0, 0]
print(arraySecond.and(arrayFirst)); // [0, 0]
print(arrayBoth.and(arrayFirst)); // [1, 0]
print(arrayBoth.and(arraySecond)); // [0, 1]
print(arrayNeither.and(arrayFirst)); // [0, 0]
print(arrayNeither.and(arraySecond)); // [0, 0]
// Works the same for all PixelTypes.
var arrayDouble = ee.Array([0.0, 2.0], ee.PixelType.double());
print(arrayBoth.and(arrayDouble)); // [0, 1]
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)
# Element-wise boolean "and" operator.
# Both arrays must be the same dimensions.
array_neither = ee.Array([0, 0])
array_first = ee.Array([1, 0])
array_second = ee.Array([0, 1])
array_both = ee.Array([1, 1])
# Any non-zero value is true.
array_larger = ee.Array([-2, 2])
display(array_both.And(array_larger)) # [1, 1]
display(array_both.And(array_neither)) # [0, 0]
display(array_first.And(array_second)) # [0, 0]
display(array_second.And(array_first)) # [0, 0]
display(array_both.And(array_first)) # [1, 0]
display(array_both.And(array_second)) # [0, 1]
display(array_neither.And(array_first)) # [0, 0]
display(array_neither.And(array_second)) # [0, 0]
# Works the same for all PixelTypes.
array_double = ee.Array([0.0, 2.0], ee.PixelType.double())
display(array_both.And(array_double)) # [0, 1]
Except as otherwise noted, the content of this page is licensed under the Creative Commons Attribution 4.0 License, and code samples are licensed under the Apache 2.0 License. For details, see the Google Developers Site Policies. Java is a registered trademark of Oracle and/or its affiliates.
Last updated 2023-12-06 UTC.
[{
"type": "thumb-down",
"id": "missingTheInformationINeed",
"label":"Missing the information I need"
},{
"type": "thumb-down",
"id": "tooComplicatedTooManySteps",
"label":"Too complicated / too many steps"
},{
"type": "thumb-down",
"id": "outOfDate",
"label":"Out of date"
},{
"type": "thumb-down",
"id": "samplesCodeIssue",
"label":"Samples / code issue"
},{
"type": "thumb-down",
"id": "otherDown",
"label":"Other"
}]
[{
"type": "thumb-up",
"id": "easyToUnderstand",
"label":"Easy to understand"
},{
"type": "thumb-up",
"id": "solvedMyProblem",
"label":"Solved my problem"
},{
"type": "thumb-up",
"id": "otherUp",
"label":"Other"
}]