公告:凡是在
2025 年 4 月 15 日前註冊使用 Earth Engine 的非商業專案,都必須
驗證非商業用途資格,才能繼續存取 Earth Engine。
ee.ImageCollection.toList
透過集合功能整理內容
你可以依據偏好儲存及分類內容。
以清單形式傳回集合的元素。
用量 | 傳回 |
---|
ImageCollection.toList(count, offset) | 清單 |
引數 | 類型 | 詳細資料 |
---|
這個:collection | FeatureCollection | 要擷取的輸入集合。 |
count | 整數 | 要擷取的元素數量上限。 |
offset | 整數,預設值為 0 | 要從開頭捨棄的元素數量。如果已設定,系統會擷取 (位移 + 數量) 個元素,並捨棄前幾個位移元素。 |
範例
程式碼編輯器 (JavaScript)
// Note: ee.ImageCollection.toList may take a lot of time and memory to run,
// since it must generate all of the results in order to gather them into a
// list. Large collections and/or complex computations can produce memory
// limitation errors.
// A Landsat 8 TOA image collection (1 year of images at a specific point).
var col = ee.ImageCollection('LANDSAT/LC08/C02/T1_TOA')
.filterBounds(ee.Geometry.Point(-90.70, 34.71))
.filterDate('2020-01-01', '2021-01-01');
print('Image collection', col);
// Get the first 3 images as a list of images.
var imgListFirst3 = col.toList(3);
print('First 3 images', imgListFirst3);
// Get the second 3 images as a list of images (use the offset parameter).
var imgListSecond3 = col.toList(3, 3);
print('Second 3 images', imgListSecond3);
Python 設定
請參閱
Python 環境頁面,瞭解 Python API 和如何使用 geemap
進行互動式開發。
import ee
import geemap.core as geemap
Colab (Python)
# Note: ee.ImageCollection.toList may take a lot of time and memory to run,
# since it must generate all of the results in order to gather them into a
# list. Large collections and/or complex computations can produce memory
# limitation errors.
# A Landsat 8 TOA image collection (1 year of images at a specific point).
col = ee.ImageCollection('LANDSAT/LC08/C02/T1_TOA').filterBounds(
ee.Geometry.Point(-90.70, 34.71)).filterDate('2020-01-01', '2021-01-01')
print('Image collection:', col.getInfo())
# Get the first 3 images as a list of images.
img_list_first3 = col.toList(3)
print('First 3 images:', img_list_first3.getInfo())
# Get the second 3 images as a list of images (use the offset parameter).
img_list_second3 = col.toList(3, 3)
print('Second 3 images:', img_list_second3.getInfo())
除非另有註明,否則本頁面中的內容是採用創用 CC 姓名標示 4.0 授權,程式碼範例則為阿帕契 2.0 授權。詳情請參閱《Google Developers 網站政策》。Java 是 Oracle 和/或其關聯企業的註冊商標。
上次更新時間:2025-07-26 (世界標準時間)。
[null,null,["上次更新時間:2025-07-26 (世界標準時間)。"],[[["\u003cp\u003e\u003ccode\u003etoList\u003c/code\u003e retrieves elements from an ImageCollection and returns them as a List.\u003c/p\u003e\n"],["\u003cp\u003eIt allows you to specify the maximum number of elements to fetch using the \u003ccode\u003ecount\u003c/code\u003e parameter.\u003c/p\u003e\n"],["\u003cp\u003eYou can control the starting position for element retrieval with the optional \u003ccode\u003eoffset\u003c/code\u003e parameter.\u003c/p\u003e\n"],["\u003cp\u003eIt's important to note that \u003ccode\u003etoList\u003c/code\u003e can be resource-intensive for large collections, potentially leading to memory limitations.\u003c/p\u003e\n"]]],["The function `ImageCollection.toList()` converts a collection's elements into a list. It takes a `count` argument, specifying the maximum number of elements to include. An optional `offset` argument allows discarding a set number of elements from the beginning. For example, setting a count of 3 and an offset of 3 returns elements four, five and six. The function is used with the input `collection`, a `FeatureCollection`. This process potentially demands significant resources, particularly with large collections.\n"],null,["# ee.ImageCollection.toList\n\nReturns the elements of a collection as a list.\n\n\u003cbr /\u003e\n\n| Usage | Returns |\n|---------------------------------------------|---------|\n| ImageCollection.toList`(count, `*offset*`)` | List |\n\n| Argument | Type | Details |\n|--------------------|---------------------|------------------------------------------------------------------------------------------------------------------------------------------------------|\n| this: `collection` | FeatureCollection | The input collection to fetch. |\n| `count` | Integer | The maximum number of elements to fetch. |\n| `offset` | Integer, default: 0 | The number of elements to discard from the start. If set, (offset + count) elements will be fetched and the first offset elements will be discarded. |\n\nExamples\n--------\n\n### Code Editor (JavaScript)\n\n```javascript\n// Note: ee.ImageCollection.toList may take a lot of time and memory to run,\n// since it must generate all of the results in order to gather them into a\n// list. Large collections and/or complex computations can produce memory\n// limitation errors.\n\n// A Landsat 8 TOA image collection (1 year of images at a specific point).\nvar col = ee.ImageCollection('LANDSAT/LC08/C02/T1_TOA')\n .filterBounds(ee.Geometry.Point(-90.70, 34.71))\n .filterDate('2020-01-01', '2021-01-01');\nprint('Image collection', col);\n\n// Get the first 3 images as a list of images.\nvar imgListFirst3 = col.toList(3);\nprint('First 3 images', imgListFirst3);\n\n// Get the second 3 images as a list of images (use the offset parameter).\nvar imgListSecond3 = col.toList(3, 3);\nprint('Second 3 images', imgListSecond3);\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# Note: ee.ImageCollection.toList may take a lot of time and memory to run,\n# since it must generate all of the results in order to gather them into a\n# list. Large collections and/or complex computations can produce memory\n# limitation errors.\n\n# A Landsat 8 TOA image collection (1 year of images at a specific point).\ncol = ee.ImageCollection('LANDSAT/LC08/C02/T1_TOA').filterBounds(\n ee.Geometry.Point(-90.70, 34.71)).filterDate('2020-01-01', '2021-01-01')\nprint('Image collection:', col.getInfo())\n\n# Get the first 3 images as a list of images.\nimg_list_first3 = col.toList(3)\nprint('First 3 images:', img_list_first3.getInfo())\n\n# Get the second 3 images as a list of images (use the offset parameter).\nimg_list_second3 = col.toList(3, 3)\nprint('Second 3 images:', img_list_second3.getInfo())\n```"]]