公告:凡是在
2025 年 4 月 15 日前註冊使用 Earth Engine 的非商業專案,都必須
驗證非商業用途資格,才能繼續存取 Earth Engine。
圖片資料擷取
透過集合功能整理內容
你可以依據偏好儲存及分類內容。
從 Earth Engine 取得圖像資料
如要將圖片資料從 Earth Engine 取得並儲存至 Google 雲端硬碟、Cloud Storage 或 Earth Engine 資產,您可以使用 Export
,且工作會由 Earth Engine 全權處理。如果匯出工作有資源調度問題 (例如耗時超過一天、傳回記憶體或逾時錯誤),或是您已熟悉 Apache Beam、Spark 或 Dask 等架構,可能會偏好本文所述的資料擷取方法。您可以使用 Google Cloud 工具 (例如 Dataflow 或 Dataproc) 擴充這些架構中導入的工作流程。
具體來說,本指南會說明如何使用 getPixels
或 computePixels
手動提出圖像資料要求。在本例中,「圖片資料」是指具有一致縮放和投影的多維像素值陣列。區域、比例、投影和/或維度會在要求中指定。ImageFileFormat 頁面會列出可能的輸出格式。輸出目的地包括 Cloud Storage 或任何本機掛載的目錄。手動要求會增加複雜度,但可擴充至更大的工作負載。
從現有素材資源取得圖片資料
使用 getPixels
取得現有 Earth Engine 資產的圖片資料。您可以直接將素材資源 ID 傳送至要求,因此在擷取像素之前,您無法對像素執行任何運算。系統會傳回指定區域、比例、投影和格式的像素區塊。以下範例說明如何使用 getPixels
從 MODIS 圖像集合中取得 NDVI 時間序列。
從已計算的圖片取得圖片資料
使用 computePixels
從已計算的圖片 (例如複合圖片) 取得圖片資料。使用 computePixels
,您可以透過 expression
參數傳遞計算的 ee.Image
物件。系統會傳回指定區域、比例、投影和格式的計算像素區塊。以下範例說明如何從無雲 Sentinel-2 組合圖中取得多光譜資料區塊。
手動並行處理要求
雖然您可以針對任何用途在任何數量的資料中提出要求,但建議您為較大的工作流程並行處理要求。如要同時提出許多這類要求,請使用 Earth Engine 高容量端點。您可以設定的並行要求數量,取決於並行互動要求配額。如要進一步瞭解何時使用大量傳輸量端點,請參閱 Earth Engine 大量傳輸量頁面。
多執行緒
您可以使用執行緒來提出並行要求。getPixels
和 computePixels
範例筆記本會示範這項做法。
Apache Beam
您可以使用 Apache Beam 管道將要求並行處理。這些管道可在本機上執行,也可以做為 Google Dataflow 工作執行。如需範例,請參閱 這門 Geo for Good 訓練課程或這項人類、地球和 AI 示範。其他並行處理程式庫包括 Dask 和 Apache Spark。
除非另有註明,否則本頁面中的內容是採用創用 CC 姓名標示 4.0 授權,程式碼範例則為阿帕契 2.0 授權。詳情請參閱《Google Developers 網站政策》。Java 是 Oracle 和/或其關聯企業的註冊商標。
上次更新時間:2025-07-25 (世界標準時間)。
[null,null,["上次更新時間:2025-07-25 (世界標準時間)。"],[[["\u003cp\u003eThis guide describes alternative methods for extracting image data from Earth Engine using \u003ccode\u003egetPixels\u003c/code\u003e and \u003ccode\u003ecomputePixels\u003c/code\u003e for increased scalability beyond the standard \u003ccode\u003eExport\u003c/code\u003e function.\u003c/p\u003e\n"],["\u003cp\u003e\u003ccode\u003egetPixels\u003c/code\u003e is used to retrieve raw image data from existing Earth Engine assets without any prior computation.\u003c/p\u003e\n"],["\u003cp\u003e\u003ccode\u003ecomputePixels\u003c/code\u003e allows for extracting data from computed images, such as composites, by passing an \u003ccode\u003eee.Image\u003c/code\u003e object.\u003c/p\u003e\n"],["\u003cp\u003eFor large-scale workflows, manual parallelization through multi-threading or utilizing frameworks like Apache Beam, Spark, or Dask is recommended to enhance processing efficiency.\u003c/p\u003e\n"],["\u003cp\u003eEarth Engine's high-volume endpoint and concurrent interactive request quota should be considered for managing numerous parallel requests.\u003c/p\u003e\n"]]],[],null,["# Image Data Extraction\n\nGetting image data from Earth Engine\n------------------------------------\n\n\nTo get image data from Earth Engine to Google Drive, Cloud Storage, or an Earth Engine asset,\nyou can use [`Export`](/earth-engine/guides/exporting) and the job\nis handled entirely by Earth Engine. If your export jobs have scaling issues (e.g.\ntake longer than a day, return memory or timeout errors) or you're already familiar\nwith a framework like [Apache Beam](https://beam.apache.org/),\n[Spark](https://spark.apache.org/) or [Dask](https://www.dask.org/),\nyou may prefer the data extraction methods described here. Workflows implemented in these\nframeworks can be scaled using Google Cloud tools such as\n[Dataflow](https://cloud.google.com/dataflow) or\n[Dataproc](https://cloud.google.com/dataproc).\n\n\nSpecifically, this guide describes methods for manually making requests\nfor image data using\n[`getPixels`](/earth-engine/apidocs/ee-data-getpixels) or\n[`computePixels`](/earth-engine/apidocs/ee-data-computepixels).\nHere, \"image data\" means multi-dimensional arrays of pixel values with consistent\nscale and projection. The region, scale, projection and/or dimensions are specified\nin the request. The\n[ImageFileFormat page](/earth-engine/reference/rest/v1/ImageFileFormat) lists\npossible output formats. Output destinations include Cloud Storage or any locally mounted\ndirectory. Manual requests add complexity, but can scale to larger workloads.\n\nGetting image data from existing assets\n---------------------------------------\n\nUse [`getPixels`](/earth-engine/apidocs/ee-data-getpixels)\nto get image data from existing Earth Engine assets. You\npass the asset ID directly to the request, so you can't do any computation on the pixels\nprior to extracting them. A block of pixels in the specified region, scale, projection\nand format is returned. The following example demonstrates getting time series of NDVI\nfrom a MODIS image collection using `getPixels`. \n\n|----------------------------------------------------------------------------------------------------------------------------------------------------------------------|--------------------------------------------------------------------------------------------------------------------------------------------------|\n| [Run in Google Colab](https://colab.research.google.com/github/google/earthengine-community/blob/master/guides/linked/Earth_Engine_training_patches_getPixels.ipynb) | [View source on GitHub](https://github.com/google/earthengine-community/blob/master/guides/linked/Earth_Engine_training_patches_getPixels.ipynb) |\n\nGetting image data from computed images\n---------------------------------------\n\n\nUse [`computePixels`](/earth-engine/apidocs/ee-data-computepixels)\nto get image data from a computed image, for example a composite. With\n[`computePixels`](/earth-engine/apidocs/ee-data-computepixels),\nyou pass a computed `ee.Image` object through the `expression`\nparameter. A block of computed pixels in the specified region, scale, projection and\nformat is returned. The following example shows getting patches of multispectral data\nfrom a cloud-free Sentinel-2 composite. \n\n|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------|------------------------------------------------------------------------------------------------------------------------------------------------------|\n| [Run in Google Colab](https://colab.research.google.com/github/google/earthengine-community/blob/master/guides/linked/Earth_Engine_training_patches_computePixels.ipynb) | [View source on GitHub](https://github.com/google/earthengine-community/blob/master/guides/linked/Earth_Engine_training_patches_computePixels.ipynb) |\n\nManual parallelization of requests\n----------------------------------\n\n\nThough you can make requests for any purpose in any volume, you may want to parallelize\nrequests for larger workflows. To make many such requests in parallel, you should use\nthe [Earth Engine high volume endpoint](/earth-engine/cloud/highvolume).\nThe number of parallel requests you can have is set by your\n[concurrent\ninteractive request quota](/earth-engine/guides/usage#concurrent_interactive_requests). See the [Earth\nEngine high volume page](/earth-engine/cloud/highvolume) for details on when to use the high volume endpoint.\n\n### Multi-threading\n\nYou can use threads to make concurrrent requests. This approach is demonstrated in the\n`getPixels` and `computePixels` example notebooks.\n\n### Apache Beam\n\n\nYou can use [Apache Beam](https://beam.apache.org/) pipelines to parallelize\nrequests. These pipelines can be run locally or as Google Dataflow jobs. For examples, see\n[this Geo for Good training](https://earthoutreachonair.withgoogle.com/events/geoforgood22?talk=day1-trackthree-talk2) or\n[this People, Planet and AI demonstration](https://github.com/GoogleCloudPlatform/python-docs-samples/tree/main/people-and-planet-ai/land-cover-classification). Alternatively, other parallelization\nlibraries include [Dask](https://www.dask.org/) and\n[Apache Spark](https://spark.apache.org/)."]]