お知らせ:
2025 年 4 月 15 日より前に Earth Engine の使用を登録したすべての非商用プロジェクトは、Earth Engine へのアクセスを維持するために
非商用目的での利用資格を確認する必要があります。
ee.data.getPixels (Python only)
コレクションでコンテンツを整理
必要に応じて、コンテンツの保存と分類を行います。
画像アセットからピクセルを取得します。
戻り値:
ピクセルを未加工の画像データとして返します。
用途 | 戻り値 |
ee.data.getPixels(params) | Object|Value |
引数 | タイプ | 詳細 |
params | オブジェクト | 次の値を持つパラメータを含むオブジェクト: 、assetId - ピクセルを取得するアセットの ID。画像アセットである必要があります。
fileFormat - 結果のファイル形式。デフォルトは png です。使用可能な形式については、ImageFileFormat をご覧ください。ダウンロードしたオブジェクトを Python データ オブジェクトに変換する追加の形式があります。これには、構造化された NumPy 配列に変換する NUMPY_NDARRAY が含まれます。
grid - データを取得するピクセル グリッドを記述するパラメータ。デフォルトでは、データのネイティブ ピクセル グリッドになります。
region - 指定されている場合、返されるデータの領域。GeoJSON ジオメトリ オブジェクトとして指定します(RFC 7946 を参照)。
bandIds - 存在する場合、ピクセルを取得する特定のバンドセットを指定します。
visualizationOptions - 存在する場合、生データを返すのではなく、データの 8 ビット RGB 可視化を生成するために適用する可視化オプションのセット。 |
例
Python の設定
Python API とインタラクティブな開発での geemap
の使用については、
Python 環境のページをご覧ください。
import ee
import geemap.core as geemap
Colab(Python)
# Region of interest.
coords = [
-121.58626826832939,
38.059141484827485,
]
region = ee.Geometry.Point(coords)
# Get a Sentinel-2 image.
image = (ee.ImageCollection('COPERNICUS/S2')
.filterBounds(region)
.filterDate('2020-04-01', '2020-09-01')
.sort('CLOUD_COVERAGE_ASSESSMENT')
.first())
image_id = image.getInfo()['id']
# Make a projection to discover the scale in degrees.
proj = ee.Projection('EPSG:4326').atScale(10).getInfo()
# Get scales out of the transform.
scale_x = proj['transform'][0]
scale_y = -proj['transform'][4]
# Make a request object.
request = {
'assetId': image_id,
'fileFormat': 'PNG',
'bandIds': ['B4', 'B3', 'B2'],
'grid': {
'dimensions': {
'width': 640,
'height': 640
},
'affineTransform': {
'scaleX': scale_x,
'shearX': 0,
'translateX': coords[0],
'shearY': 0,
'scaleY': scale_y,
'translateY': coords[1]
},
'crsCode': proj['crs'],
},
'visualizationOptions': {'ranges': [{'min': 0, 'max': 3000}]},
}
image_png = ee.data.getPixels(request)
# Do something with the image...
特に記載のない限り、このページのコンテンツはクリエイティブ・コモンズの表示 4.0 ライセンスにより使用許諾されます。コードサンプルは Apache 2.0 ライセンスにより使用許諾されます。詳しくは、Google Developers サイトのポリシーをご覧ください。Java は Oracle および関連会社の登録商標です。
最終更新日 2025-07-26 UTC。
[null,null,["最終更新日 2025-07-26 UTC。"],[[["\u003cp\u003e\u003ccode\u003eee.data.getPixels\u003c/code\u003e fetches raw image data or visualized 8-bit RGB data from an Earth Engine image asset.\u003c/p\u003e\n"],["\u003cp\u003eThe function requires specifying the asset ID and allows customization of file format, pixel grid, region, bands, and visualization options.\u003c/p\u003e\n"],["\u003cp\u003eUsers can define the output region, select specific bands for extraction, and apply visualization parameters for an RGB representation.\u003c/p\u003e\n"],["\u003cp\u003ePython examples demonstrate the usage of \u003ccode\u003eee.data.getPixels\u003c/code\u003e with the necessary parameters and retrieving image data.\u003c/p\u003e\n"]]],[],null,["# ee.data.getPixels (Python only)\n\n\u003cbr /\u003e\n\nFetches pixels from an image asset.\n\n\u003cbr /\u003e\n\nReturns:\nThe pixels as raw image data.\n\n| Usage | Returns |\n|-----------------------------|---------------|\n| `ee.data.getPixels(params)` | Object\\|Value |\n\n| Argument | Type | Details |\n|----------|--------|-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| `params` | Object | An object containing parameters with the following possible values: `assetId` - The asset ID for which to get pixels. Must be an image asset. `fileFormat` - The resulting file format. Defaults to png. See [ImageFileFormat](https://developers.google.com/earth-engine/reference/rest/v1/ImageFileFormat) for the available formats. There are additional formats that convert the downloaded object to a Python data object. These include: `NUMPY_NDARRAY`, which converts to a structured NumPy array. `grid` - Parameters describing the pixel grid in which to fetch data. Defaults to the native pixel grid of the data. `region` - If present, the region of data to return, specified as a GeoJSON geometry object (see RFC 7946). `bandIds` - If present, specifies a specific set of bands from which to get pixels. `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\nExamples\n--------\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# Region of interest.\ncoords = [\n -121.58626826832939,\n 38.059141484827485,\n]\nregion = ee.Geometry.Point(coords)\n\n# Get a Sentinel-2 image.\nimage = (ee.ImageCollection('COPERNICUS/S2')\n .filterBounds(region)\n .filterDate('2020-04-01', '2020-09-01')\n .sort('CLOUD_COVERAGE_ASSESSMENT')\n .first())\nimage_id = image.getInfo()['id']\n\n# Make a projection to discover the scale in degrees.\nproj = ee.Projection('EPSG:4326').atScale(10).getInfo()\n\n# Get scales out of the transform.\nscale_x = proj['transform'][0]\nscale_y = -proj['transform'][4]\n\n# Make a request object.\nrequest = {\n 'assetId': image_id,\n 'fileFormat': 'PNG',\n 'bandIds': ['B4', 'B3', 'B2'],\n 'grid': {\n 'dimensions': {\n 'width': 640,\n 'height': 640\n },\n 'affineTransform': {\n 'scaleX': scale_x,\n 'shearX': 0,\n 'translateX': coords[0],\n 'shearY': 0,\n 'scaleY': scale_y,\n 'translateY': coords[1]\n },\n 'crsCode': proj['crs'],\n },\n 'visualizationOptions': {'ranges': [{'min': 0, 'max': 3000}]},\n}\n\nimage_png = ee.data.getPixels(request)\n# Do something with the image...\n```"]]