Announcement: All noncommercial projects registered to use Earth Engine before April 15, 2025 must verify noncommercial eligibility to maintain Earth Engine access.
[[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Missing the information I need","missingTheInformationINeed","thumb-down"],["Too complicated / too many steps","tooComplicatedTooManySteps","thumb-down"],["Out of date","outOfDate","thumb-down"],["Samples / code issue","samplesCodeIssue","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2023-12-06 UTC."],[[["\u003cp\u003e\u003ccode\u003eArray.and()\u003c/code\u003e performs an element-wise boolean "and" operation on two input arrays.\u003c/p\u003e\n"],["\u003cp\u003eIt returns 1 for each element if and only if both corresponding elements in the input arrays are non-zero, otherwise it returns 0.\u003c/p\u003e\n"],["\u003cp\u003eThe input arrays must have the same dimensions.\u003c/p\u003e\n"],["\u003cp\u003eAny non-zero value is considered as true for the purpose of this operation.\u003c/p\u003e\n"]]],[],null,["# ee.Array.and\n\nOn an element-wise basis, returns 1 if and only if both values are non-zero.\n\n\u003cbr /\u003e\n\n| Usage | Returns |\n|--------------------|---------|\n| Array.and`(right)` | Array |\n\n| Argument | Type | Details |\n|--------------|-------|-----------------------|\n| this: `left` | Array | The left-hand value. |\n| `right` | Array | The right-hand value. |\n\nExamples\n--------\n\n### Code Editor (JavaScript)\n\n```javascript\n// Element-wise boolean \"and\" operator.\n// Both arrays must be the same dimensions.\nvar arrayNeither = ee.Array([0, 0]);\nvar arrayFirst = ee.Array([1, 0]);\nvar arraySecond = ee.Array([0, 1]);\nvar arrayBoth = ee.Array([1, 1]);\n// Any non-zero value is true.\nvar arrayLarger = ee.Array([-2, 2]);\n\nprint(arrayBoth.and(arrayLarger)); // [1, 1]\nprint(arrayBoth.and(arrayNeither)); // [0, 0]\n\nprint(arrayFirst.and(arraySecond)); // [0, 0]\nprint(arraySecond.and(arrayFirst)); // [0, 0]\n\nprint(arrayBoth.and(arrayFirst)); // [1, 0]\nprint(arrayBoth.and(arraySecond)); // [0, 1]\n\nprint(arrayNeither.and(arrayFirst)); // [0, 0]\nprint(arrayNeither.and(arraySecond)); // [0, 0]\n\n// Works the same for all PixelTypes.\nvar arrayDouble = ee.Array([0.0, 2.0], ee.PixelType.double());\nprint(arrayBoth.and(arrayDouble)); // [0, 1]\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# Element-wise boolean \"and\" operator.\n# Both arrays must be the same dimensions.\narray_neither = ee.Array([0, 0])\narray_first = ee.Array([1, 0])\narray_second = ee.Array([0, 1])\narray_both = ee.Array([1, 1])\n# Any non-zero value is true.\narray_larger = ee.Array([-2, 2])\n\ndisplay(array_both.And(array_larger)) # [1, 1]\ndisplay(array_both.And(array_neither)) # [0, 0]\n\ndisplay(array_first.And(array_second)) # [0, 0]\ndisplay(array_second.And(array_first)) # [0, 0]\n\ndisplay(array_both.And(array_first)) # [1, 0]\ndisplay(array_both.And(array_second)) # [0, 1]\n\ndisplay(array_neither.And(array_first)) # [0, 0]\ndisplay(array_neither.And(array_second)) # [0, 0]\n\n# Works the same for all PixelTypes.\narray_double = ee.Array([0.0, 2.0], ee.PixelType.double())\ndisplay(array_both.And(array_double)) # [0, 1]\n```"]]