公告:所有在
2025 年 4 月 15 日之前注册使用 Earth Engine 的非商业项目都必须
验证是否符合非商业性质的资格条件,才能继续使用 Earth Engine。
Method: projects.assets.getPixels
使用集合让一切井井有条
根据您的偏好保存内容并对其进行分类。
从图片素材资源提取像素。借助此自定义方法,调用方可以请求从图片中获取任意像素图块,并可选择指定波段和地图投影。经过脱敏处理或缺失的数据将编码为零。
每个请求的未压缩数据量限制为 48MB,计算方式为请求尺寸(以像素为单位)、请求的图像波段数以及每个波段的每个像素字节数的乘积。请求的任一尺寸不得超过 32K 像素,且不得超过 1024 个波段。超出这些限制的请求将导致错误代码为 400 (BAD_REQUEST)。
如果成功,响应正文将包含请求的像素数据,采用请求的 fileFormat
字段中指定的编码。
HTTP 请求
POST https://earthengine.googleapis.com/v1/{name=projects/*/assets/**}:getPixels
网址采用 gRPC 转码语法。
路径参数
参数 |
name |
string
必需。要从中获取像素的图片素材资源的名称。name 的格式为“projects/*/assets/**”(例如“projects/earthengine-legacy/assets/users/[USER]/[ASSET]”)。所有用户拥有的资产都位于项目“earthengine-legacy”下(例如,“projects/earthengine-legacy/assets/users/foo/bar”)。所有其他资产均位于项目“earthengine-public”下(例如"projects/earthengine-public/assets/LANDSAT").
必须对指定的资源 name 具有以下 IAM 权限才能进行授权:
|
请求正文
请求正文中包含结构如下的数据:
字段 |
fileFormat |
enum (ImageFileFormat )
用于返回像素值的输出文件格式。
|
grid |
object (PixelGrid )
用于描述要提取数据的像素网格的参数。默认为数据的原生像素网格。
|
region |
object (Struct format)
要返回的数据区域(如果有),以 GeoJSON 几何图形对象的形式指定(请参阅 RFC 7946)。由于返回的图像始终是矩形,因此实际上会使用输出坐标系中给定几何图形的边界框。如果还指定了 grid.dimensions ,则网格最终会按请求的大小重新缩放。
|
bandIds[] |
string
如果存在,则指定要从中获取像素的一组特定波段。频段由 ID 标识,如 ImageBand proto 的 id 字段所示。
|
visualizationOptions |
object (VisualizationOptions )
一组可视化选项(如果有),用于生成数据的 8 位 RGB 可视化图表,而不是返回原始数据。
|
workloadTag |
string
用户提供的用于跟踪此计算的代码。
|
响应正文
如果成功,则响应为通用 HTTP 响应,其格式由方法定义。
授权范围
需要以下 OAuth 范围之一:
https://www.googleapis.com/auth/earthengine
https://www.googleapis.com/auth/earthengine.readonly
https://www.googleapis.com/auth/cloud-platform
https://www.googleapis.com/auth/cloud-platform.read-only
如需了解详情,请参阅 OAuth 2.0 Overview。
如未另行说明,那么本页面中的内容已根据知识共享署名 4.0 许可获得了许可,并且代码示例已根据 Apache 2.0 许可获得了许可。有关详情,请参阅 Google 开发者网站政策。Java 是 Oracle 和/或其关联公司的注册商标。
最后更新时间 (UTC):2025-07-25。
[null,null,["最后更新时间 (UTC):2025-07-25。"],[[["\u003cp\u003eFetches pixel data from Earth Engine image assets, allowing users to specify bands, regions, and output formats.\u003c/p\u003e\n"],["\u003cp\u003eRequests are limited to 48MB uncompressed data, 32K pixels in each dimension, and 1024 bands; exceeding these limits results in a 400 error.\u003c/p\u003e\n"],["\u003cp\u003ePixel data can be returned in various formats, including raw data and visualizations based on specified parameters.\u003c/p\u003e\n"],["\u003cp\u003eRequires authorization using one of the specified OAuth scopes for access.\u003c/p\u003e\n"],["\u003cp\u003eUsers can provide a workload tag for tracking the computation.\u003c/p\u003e\n"]]],[],null,["# Method: projects.assets.getPixels\n\nFetches pixels from an image asset. This custom method allows the caller to request an arbitrary tile of pixels from an image, optionally specifying the bands and map projection. Masked or missing data will be encoded as zeroes.\n\nRequests are limited to 48MB in uncompressed data per request, computed as the product of the request dimensions in pixels, the number of image bands requested, and the number of bytes per pixel for each band. Requests are also limited to at most 32K pixels in either dimension and at most 1024 bands. Requests exceeding these limits will result in an error code of 400 (BAD_REQUEST).\n\nIf successful, the response body contains the requested pixel data in the encoding specified in the `fileFormat` field of the request.\n\n### HTTP request\n\n`POST https://earthengine.googleapis.com/v1/{name=projects/*/assets/**}:getPixels`\n\nThe URL uses [gRPC Transcoding](https://google.aip.dev/127) syntax.\n\n### Path parameters\n\n| Parameters ||\n|--------|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| `name` | `string` Required. The name of the image asset from which to get pixels. `name` is of the format \"projects/\\*/assets/\\*\\*\" (e.g., \"projects/earthengine-legacy/assets/users/\\[USER\\]/\\[ASSET\\]\"). All user-owned assets are under the project \"earthengine-legacy\" (e.g., \"projects/earthengine-legacy/assets/users/foo/bar\"). All other assets are under the project \"earthengine-public\" (e.g., \"projects/earthengine-public/assets/LANDSAT\"). Authorization requires the following [IAM](https://cloud.google.com/iam/docs/) permission on the specified resource `name`: - `earthengine.assets.get` |\n\n### Request body\n\nThe request body contains data with the following structure:\n\n| JSON representation |\n|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| ``` { \"fileFormat\": enum (/earth-engine/reference/rest/v1/ImageFileFormat), \"grid\": { object (/earth-engine/reference/rest/v1/PixelGrid) }, \"region\": { object }, \"bandIds\": [ string ], \"visualizationOptions\": { object (/earth-engine/reference/rest/v1/VisualizationOptions) }, \"workloadTag\": string } ``` |\n\n| Fields ||\n|------------------------|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| `fileFormat` | `enum (`[ImageFileFormat](/earth-engine/reference/rest/v1/ImageFileFormat)`)` The output file format in which to return the pixel values. |\n| `grid` | `object (`[PixelGrid](/earth-engine/reference/rest/v1/PixelGrid)`)` Parameters describing the pixel grid in which to fetch data. Defaults to the native pixel grid of the data. |\n| `region` | `object (`[Struct](https://protobuf.dev/reference/protobuf/google.protobuf/#struct)` format)` If present, the region of data to return, specified as a GeoJSON geometry object (see RFC 7946). Since the returned image is always rectangular, the bounding box of the given geometry in the output coordinate system will actually be used. If `grid.dimensions` is also specified then the grid will finally be rescaled to the requested size. |\n| `bandIds[]` | `string` If present, specifies a specific set of bands from which to get pixels. Bands are identified by id, as indicated by the `id` field of an ImageBand proto. |\n| `visualizationOptions` | `object (`[VisualizationOptions](/earth-engine/reference/rest/v1/VisualizationOptions)`)` If present, a set of visualization options to apply to produce an 8-bit RGB visualization of the data, rather than returning the raw data. |\n| `workloadTag` | `string` User supplied tag to track this computation. |\n\n### Response body\n\nIf successful, the response is a generic HTTP response whose format is defined by the method.\n\n### Authorization scopes\n\nRequires one of the following OAuth scopes:\n\n- `https://www.googleapis.com/auth/earthengine`\n- `\n https://www.googleapis.com/auth/earthengine.readonly`\n- `\n https://www.googleapis.com/auth/cloud-platform`\n- `\n https://www.googleapis.com/auth/cloud-platform.read-only`\n\nFor more information, see the [OAuth 2.0 Overview](/identity/protocols/OAuth2)."]]