Announcement : All noncommercial projects registered to use Earth Engine before
April 15, 2025 must
verify noncommercial eligibility to maintain Earth Engine access.
Send feedback
ee.Array.cat
Stay organized with collections
Save and categorize content based on your preferences.
Concatenates multiple arrays into a single array along the given axis. Each array must have the same dimensionality and the same length on all axes except the concatenation axis.
Usage Returns ee.Array.cat(arrays, axis )
Array
Argument Type Details arrays
List Arrays to concatenate. axis
Integer, default: 0 Axis to concatenate along.
Examples
Code Editor (JavaScript)
// Requires an explicit PixelType if no data.
var empty = ee . Array ([], ee . PixelType . int8 ()); // Empty []
var one = ee . Array ([ 1 ]);
var two = ee . Array ([ 2 ]);
print ( ee . Array . cat ([ empty ])); // []
print ( ee . Array . cat ([ empty , empty ])); // []
print ( ee . Array . cat ([ empty , one ])); // [1]
print ( ee . Array . cat ([ one , empty ])); // [1]
print ( ee . Array . cat ([ one , two ])); // [1, 2]
print ( ee . Array . cat ([ one , two ], 0 )); // [1, 2]
print ( ee . Array . cat ([ one , two ], 1 )); // [[1,2]]
var a = ee . Array ([ 0 , 1 , 2 ]);
var b = ee . Array ([ 3 , 4 , 5 ]);
print ( ee . Array . cat ([ a , b ])); // [0,1,2,3,4,5]
print ( ee . Array . cat ([ a , b ], 0 )); // [0,1,2,3,4,5]
print ( ee . Array . cat ([ a , b ], 1 )); // [[0,3],[1,4],[2,5]]
var c = ee . Array ([[ 0 ], [ 1 ], [ 2 ]]);
var d = ee . Array ([[ 3 ], [ 4 ], [ 5 ]]);
print ( ee . Array . cat ([ c , d ])); // [[0],[1],[2],[3],[4],[5]]
print ( ee . Array . cat ([ c , d ], 0 )); // [[0],[1],[2],[3],[4],[5]]
print ( ee . Array . cat ([ c , d ], 1 )); // [[0,3],[1,4],[2,5]]
print ( ee . Array . cat ([ c , d ], 2 )); // [[[0,3]],[[1,4]],[[2,5]]]
var e = ee . Array ([[[ 0 , 1 ], [ 2 , 3 ]], [[ 4 , 5 ], [ 6 , 7 ]]]);
var f = ee . Array ([[[ 10 , 11 ], [ 12 , 13 ]], [[ 14 , 15 ], [ 16 , 17 ]]]);
// [[[0,1],[2,3]]
// [[4,5],[6,7]]
// [[10,11],[12,13]]
// [[14,15],[16,17]]
print ( ee . Array . cat ([ e , f ], 0 ));
// [[[0,1],[2,3],[10,11],[12,13]]
// [[4,5],[6,7],[14,15],[16,17]]]
print ( ee . Array . cat ([ e , f ], 1 ));
// [[[0,1,10,11],[2,3,12,13]]
// [[4,5,14,15],[6,7,16,17]]]
print ( ee . Array . cat ([ e , f ], 2 ));
// [[[[0,10],[1,11]],[[2,12],[3,13]]]
// [[[4,14],[5,15]],[[6,16],[7,17]]]]
print ( ee . Array . cat ([ e , f ], 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)
# Requires an explicit PixelType if no data.
empty = ee . Array ([], ee . PixelType . int8 ()) # []
one = ee . Array ([ 1 ])
two = ee . Array ([ 2 ])
display ( ee . Array . cat ([ empty ])) # []
display ( ee . Array . cat ([ empty , empty ])) # []
display ( ee . Array . cat ([ empty , one ])) # [1]
display ( ee . Array . cat ([ one , empty ])) # [1]
display ( ee . Array . cat ([ one , two ])) # [1, 2]
display ( ee . Array . cat ([ one , two ], 0 )) # [1, 2]
display ( ee . Array . cat ([ one , two ], 1 )) # [[1, 2]]
a = ee . Array ([ 0 , 1 , 2 ])
b = ee . Array ([ 3 , 4 , 5 ])
display ( ee . Array . cat ([ a , b ])) # [0, 1, 2, 3, 4, 5]
display ( ee . Array . cat ([ a , b ], 0 )) # [0, 1, 2, 3, 4, 5]
display ( ee . Array . cat ([ a , b ], 1 )) # [[0, 3], [1, 4], [2, 5]]
c = ee . Array ([[ 0 ], [ 1 ], [ 2 ]])
d = ee . Array ([[ 3 ], [ 4 ], [ 5 ]])
display ( ee . Array . cat ([ c , d ])) # [[0], [1], [2], [3], [4], [5]]
display ( ee . Array . cat ([ c , d ], 0 )) # [[0], [1], [2], [3], [4], [5]]
display ( ee . Array . cat ([ c , d ], 1 )) # [[0, 3], [1, 4], [2, 5]]
display ( ee . Array . cat ([ c , d ], 2 )) # [[[0, 3]], [[1, 4]], [[2, 5]]]
e = ee . Array ([[[ 0 , 1 ], [ 2 , 3 ]], [[ 4 , 5 ], [ 6 , 7 ]]])
f = ee . Array ([[[ 10 , 11 ], [ 12 , 13 ]], [[ 14 , 15 ], [ 16 , 17 ]]])
# [[[0, 1], [2, 3]]
# [[4, 5], [6, 7]]
# [[10, 11], [12, 13]]
# [[14, 15], [16, 17]]
display ( ee . Array . cat ([ e , f ], 0 ))
# [[[0, 1], [2, 3], [10, 11], [12, 13]]
# [[4, 5], [6, 7], [14, 15], [16, 17]]]
display ( ee . Array . cat ([ e , f ], 1 ))
# [[[0, 1, 10, 11], [2, 3, 12, 13]]
# [[4, 5, 14, 15], [6, 7, 16, 17]]]
display ( ee . Array . cat ([ e , f ], 2 ))
# [[[[0, 10], [1, 11]], [[2, 12], [3, 13]]]
# [[[4, 14], [5, 15]], [[6, 16], [7, 17]]]]
display ( ee . Array . cat ([ e , f ], 3 ))
Send feedback
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 2024-07-13 UTC.
Need to tell us more?
[[["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 2024-07-13 UTC."],[[["\u003cp\u003e\u003ccode\u003eee.Array.cat()\u003c/code\u003e combines multiple arrays into a single array.\u003c/p\u003e\n"],["\u003cp\u003eThe \u003ccode\u003eaxis\u003c/code\u003e parameter specifies the dimension along which the concatenation occurs (defaults to 0).\u003c/p\u003e\n"],["\u003cp\u003eInput arrays must have the same dimensionality and be of the same length in all dimensions except the concatenation axis.\u003c/p\u003e\n"],["\u003cp\u003eThis function is useful for merging or extending array data in Earth Engine.\u003c/p\u003e\n"]]],["`ee.Array.cat(arrays, axis)` concatenates multiple arrays into one. Input arrays must have identical dimensions and lengths across all axes except the concatenation axis. The `arrays` argument is a list of arrays to merge. The `axis` argument, defaulting to 0, specifies the axis for concatenation. Concatenating empty arrays with others results in the non-empty array or an empty array. Examples in Javascript and Python are provided to demonstrate different `axis` argument and the resulting array.\n"],null,["Concatenates multiple arrays into a single array along the given axis. Each array must have the same dimensionality and the same length on all axes except the concatenation axis.\n\n\u003cbr /\u003e\n\n| Usage | Returns |\n|----------------------------------|---------|\n| `ee.Array.cat(arrays, `*axis*`)` | Array |\n\n| Argument | Type | Details |\n|----------|---------------------|----------------------------|\n| `arrays` | List | Arrays to concatenate. |\n| `axis` | Integer, default: 0 | Axis to concatenate along. |\n\nExamples\n\nCode Editor (JavaScript) \n\n```javascript\n// Requires an explicit PixelType if no data.\nvar empty = ee.Array([], ee.PixelType.int8()); // Empty []\nvar one = ee.Array([1]);\nvar two = ee.Array([2]);\n\nprint(ee.Array.cat([empty])); // []\nprint(ee.Array.cat([empty, empty])); // []\nprint(ee.Array.cat([empty, one])); // [1]\nprint(ee.Array.cat([one, empty])); // [1]\nprint(ee.Array.cat([one, two])); // [1, 2]\n\nprint(ee.Array.cat([one, two], 0)); // [1, 2]\nprint(ee.Array.cat([one, two], 1)); // [[1,2]]\n\nvar a = ee.Array([0, 1, 2]);\nvar b = ee.Array([3, 4, 5]);\nprint(ee.Array.cat([a, b])); // [0,1,2,3,4,5]\nprint(ee.Array.cat([a, b], 0)); // [0,1,2,3,4,5]\nprint(ee.Array.cat([a, b], 1)); // [[0,3],[1,4],[2,5]]\n\nvar c = ee.Array([[0], [1], [2]]);\nvar d = ee.Array([[3], [4], [5]]);\nprint(ee.Array.cat([c, d])); // [[0],[1],[2],[3],[4],[5]]\nprint(ee.Array.cat([c, d], 0)); // [[0],[1],[2],[3],[4],[5]]\nprint(ee.Array.cat([c, d], 1)); // [[0,3],[1,4],[2,5]]\nprint(ee.Array.cat([c, d], 2)); // [[[0,3]],[[1,4]],[[2,5]]]\n\nvar e = ee.Array([[[0, 1], [2, 3]], [[4, 5], [6, 7]]]);\nvar f = ee.Array([[[10, 11], [12, 13]], [[14, 15], [16, 17]]]);\n\n// [[[0,1],[2,3]]\n// [[4,5],[6,7]]\n// [[10,11],[12,13]]\n// [[14,15],[16,17]]\nprint(ee.Array.cat([e, f], 0));\n\n// [[[0,1],[2,3],[10,11],[12,13]]\n// [[4,5],[6,7],[14,15],[16,17]]]\nprint(ee.Array.cat([e, f], 1));\n\n// [[[0,1,10,11],[2,3,12,13]]\n// [[4,5,14,15],[6,7,16,17]]]\nprint(ee.Array.cat([e, f], 2));\n\n// [[[[0,10],[1,11]],[[2,12],[3,13]]]\n// [[[4,14],[5,15]],[[6,16],[7,17]]]]\nprint(ee.Array.cat([e, f], 3));\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\nColab (Python) \n\n```python\n# Requires an explicit PixelType if no data.\nempty = ee.Array([], ee.PixelType.int8()) # []\none = ee.Array([1])\ntwo = ee.Array([2])\n\ndisplay(ee.Array.cat([empty])) # []\ndisplay(ee.Array.cat([empty, empty])) # []\ndisplay(ee.Array.cat([empty, one])) # [1]\ndisplay(ee.Array.cat([one, empty])) # [1]\ndisplay(ee.Array.cat([one, two])) # [1, 2]\n\ndisplay(ee.Array.cat([one, two], 0)) # [1, 2]\ndisplay(ee.Array.cat([one, two], 1)) # [[1, 2]]\n\na = ee.Array([0, 1, 2])\nb = ee.Array([3, 4, 5])\ndisplay(ee.Array.cat([a, b])) # [0, 1, 2, 3, 4, 5]\ndisplay(ee.Array.cat([a, b], 0)) # [0, 1, 2, 3, 4, 5]\ndisplay(ee.Array.cat([a, b], 1)) # [[0, 3], [1, 4], [2, 5]]\n\nc = ee.Array([[0], [1], [2]])\nd = ee.Array([[3], [4], [5]])\ndisplay(ee.Array.cat([c, d])) # [[0], [1], [2], [3], [4], [5]]\ndisplay(ee.Array.cat([c, d], 0)) # [[0], [1], [2], [3], [4], [5]]\ndisplay(ee.Array.cat([c, d], 1)) # [[0, 3], [1, 4], [2, 5]]\ndisplay(ee.Array.cat([c, d], 2)) # [[[0, 3]], [[1, 4]], [[2, 5]]]\n\ne = ee.Array([[[0, 1], [2, 3]], [[4, 5], [6, 7]]])\nf = ee.Array([[[10, 11], [12, 13]], [[14, 15], [16, 17]]])\n\n# [[[0, 1], [2, 3]]\n# [[4, 5], [6, 7]]\n# [[10, 11], [12, 13]]\n# [[14, 15], [16, 17]]\ndisplay(ee.Array.cat([e, f], 0))\n\n# [[[0, 1], [2, 3], [10, 11], [12, 13]]\n# [[4, 5], [6, 7], [14, 15], [16, 17]]]\ndisplay(ee.Array.cat([e, f], 1))\n\n# [[[0, 1, 10, 11], [2, 3, 12, 13]]\n# [[4, 5, 14, 15], [6, 7, 16, 17]]]\ndisplay(ee.Array.cat([e, f], 2))\n\n# [[[[0, 10], [1, 11]], [[2, 12], [3, 13]]]\n# [[[4, 14], [5, 15]], [[6, 16], [7, 17]]]]\ndisplay(ee.Array.cat([e, f], 3))\n```"]]