公告:所有在
2025 年 4 月 15 日之前注册使用 Earth Engine 的非商业项目都必须
验证是否符合非商业性质的资格条件,才能继续使用 Earth Engine。
图片数据提取
使用集合让一切井井有条
根据您的偏好保存内容并对其进行分类。
从 Earth Engine 获取图片数据
如需将图片数据从 Earth Engine 导出到 Google 云端硬盘、Cloud Storage 或 Earth Engine 资产,您可以使用 Export
,该作业将完全由 Earth Engine 处理。如果您的导出作业存在扩缩问题(例如,需要超过一天的时间、返回内存或超时错误),或者您已经熟悉 Apache Beam、Spark 或 Dask 等框架,则可能更倾向于使用此处介绍的数据提取方法。您可以使用 Dataflow 或 Dataproc 等 Google Cloud 工具扩展在这些框架中实现的工作流。
具体而言,本指南介绍了使用 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。
如未另行说明,那么本页面中的内容已根据知识共享署名 4.0 许可获得了许可,并且代码示例已根据 Apache 2.0 许可获得了许可。有关详情,请参阅 Google 开发者网站政策。Java 是 Oracle 和/或其关联公司的注册商标。
最后更新时间 (UTC):2025-07-25。
[null,null,["最后更新时间 (UTC):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/)."]]